Are Web Components actually useable in IE11 and Edge?

前端 未结 1 1732
独厮守ぢ
独厮守ぢ 2021-02-02 09:56

Web Components are the hot new thing, and a true web standard, everybody is talking about them and presumably using them, and they seemed like the perfect solution to a problem

相关标签:
1条回答
  • 2021-02-02 10:28

    If all you want is Custom Elements then you can get them to work with IE11 and Edge. Shadow DOM and HTML Imports can work with IE11 and Edge as well, but I, personally, don't like using Shadow DOM except on browsers that support it natively.

    Firefox and Edge will work with just the regular polyfill.

    IE11 needs to be Transpiled into ES5 and use the polyfill.

    If you are using the ES5 transpiled code on a newer browser, that supports class then you need to use the file custom-elements-es5-adapter.js

    Some people use webcomponents-lite.js which will auto-load the needed polyfill files. Others load the specific polyfill, like webcomponents-hi-ce.js (HTML Imports and Custom Elements) or webcomponents-sd-ce.js (Shady DOM and Custom Elements)

    https://github.com/webcomponents/polyfills/tree/master/packages/webcomponentsjs

    UPDATE

    If you are using a newer version of Edge, the versions that use Chromium, then support for V1 components is now built in.

    0 讨论(0)
提交回复
热议问题