Why can't you create Custom Elements in Chrome Extensions?

后端 未结 2 677
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-19 01:44

I attempted to create a custom element in a Chrome extension but customeElements.define is null.

customElements.define(\'customElement\         


        
2条回答
  •  南笙
    南笙 (楼主)
    2021-02-19 02:02

    You may want to first check this article to fully understand what custom elements do and how to build them. As discussed, in building a custom element, you also need to check if document.registerElement is available. Otherwise, you can simply load webcomponents.js to polyfill it.

    Here are additional references that you may want to check for additional insights.

    • Custom Elements v1: Reusable Web Components. Rules on creating custom elements are enumerated here.
    • Registering a custom element from a chrome extension. This requires the usage of the webcomponentsjs polyfill. Chrome will prevent native registerElement from being executed within a chrome extension.

提交回复
热议问题