npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wc-putty

v0.1.0

Published

Complementary polyfills for @webcomponents/webcomponentsjs

Downloads

7

Readme

npm version

wc-putty

Complementary polyfills for @webcomponents/webcomponentsjs

List of Polyfills

| Property/Method | Target Class | Target Browsers | Features | |:----------------|:-------------|:----------------|:------| | attributeChangedCallback() | Custom element base class | IE 11, Edge, Safari 9 | Attribute changes via properties | | children | DocumentFragment | IE 11 | | | children | SVGElement | IE 11 | | | from() | Array | IE 11 | Iterable protocol | | constructor() | Set | IE 11 | Iterable initializer | | Symbol.species| Set | IE 11 | | | Symbol.iterator | Set | IE 11 | | | values() | Set | IE 11 | | | add() | Set | IE 11 | Key equality for -0 and 0 | | has() | Set | IE 11 | Key equality for -0 and 0 | | constructor() | Map | IE 11 | Iterable initializer | | Symbol.species| Map | IE 11 | | | Symbol.iterator | Map | IE 11 | | | keys() | Map | IE 11 | | | values() | Map | IE 11 | | | entries() | Map | IE 11 | | | set() | Map | IE 11 | Key equality for -0 and 0 | | has() | Map | IE 11 | Key equality for -0 and 0 |

Install

    npm install wc-putty

Import

    import { polyfill } from 'wc-putty/polyfill.js';

Usage

    // Polyfilled only on IE11, Edge, and Safari 9
    class MyElement extends polyfill(HTMLElement) {
      static get observedAttributes() { return [ 'lang' ] }
      attributeChangedCallback(name, oldValue, newValue) {
        // Attribute changes via built-in properties such as lang are detected properly
        // Attribute changes via setAttribute() are detected and the method is called only once per change
      }
    }
    customElements.define('my-element', MyElement);
    // Triggers attributeChangedCallback('lang', null, 'en-US')
    document.createElement('my-element').lang = 'en-US';

    // Polyfilled only on IE 11
    // Set
    let set = new Set([0, -0, 1]);
    set.size === 2; // key equality for -0 and 0
    set.has(-0) && set.has(0) && set.has(1);
    [...set]; // spread iterable
    for (let item of set) {} // iterate over a Set object
    // Map
    let map = new Map((function * () { yield * [0, -0, 1]; })());
    map.size === 2; // key equality for -0 and 0
    map.has(-0) && map.has(0) && map.has(1);

Notes

  • The polyfills are complementary to @webcomponents/webcomponentsjs
    • @webcomponents/webcomponentsjs/webcomponents-{bundle|loader}.js have to be loaded beforehand
  • The polyfills are adaptive
    • They do not touch the target classes if the features are supported natively or currently polyfilled and functional
  • Global objects are polyfilled except for attributeChangedCallback()
  • The main module polyfill.js is provided as an ES module and evaluated only once to polyfill the target global objects
  • Transpilation for the target browsers is required
    • Basic polyfills such as babel runtime have to be loaded beforehand
  • Bundling is required if the target browser does not support ES modules natively
  • Attribute changes via setAttributeNS() can trigger 2 calls of attributeChangedCallback() if polyfilled by polyfill() mixin

License

BSD-2-Clause