Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wc-putty

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wc-putty

Complementary polyfills for @webcomponents/webcomponentsjs

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

npm version

wc-putty

Complementary polyfills for @webcomponents/webcomponentsjs

List of Polyfills

Property/MethodTarget ClassTarget BrowsersFeatures
attributeChangedCallback()Custom element base classIE 11, Edge, Safari 9Attribute changes via properties
childrenDocumentFragmentIE 11
childrenSVGElementIE 11
from()ArrayIE 11Iterable protocol
constructor()SetIE 11Iterable initializer
Symbol.speciesSetIE 11
Symbol.iteratorSetIE 11
values()SetIE 11
add()SetIE 11Key equality for -0 and 0
has()SetIE 11Key equality for -0 and 0
constructor()MapIE 11Iterable initializer
Symbol.speciesMapIE 11
Symbol.iteratorMapIE 11
keys()MapIE 11
values()MapIE 11
entries()MapIE 11
set()MapIE 11Key equality for -0 and 0
has()MapIE 11Key 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

Keywords

FAQs

Package last updated on 01 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc