Webcomponentjs polyfill for v1 spec

553 views Asked by At

Is there a polyfill for the Web Components v1 spec available? I'm looking for a way to create components using customElements.define instead of document.registerElement.

2

There are 2 answers

0
Supersharp On

If you want to polyfill only Custom Elements v1 (implementing customeElements.define) you have the choice between 2 polyfills:


If you want to polyfill the whole Web Components stack, you can use the v1 branch of the webcomponentsjs polyfill, since the current release (v0.7.23) doesn't implement yet the Custom Element and Shadow DOM "v1" Living Standards. Note that it is not merged in the master yet and subject to changes.

You can also only load the useful polyfills depending of your needs:

  • Custom Elements v1: see above
  • HTML Imports: HTMLImport.js in the current webcomponentsjs release
  • Shadow DOM v1: ShadyDOM, and ShadyCSS
  • Templates (old browsers only :) Template.js in the current webcomponentsjs release
2
a1626 On

As mentioned by @tony19, you can use v1 branch of webcomponentsjs. You can read about it here.

Or you can install it using bower

bower i -S webcomponentsjs#v1