我在玩v1 web組件。據埃裏克Bidelman在Custom elements v1: reusable web components,一V1 Web組件可以定義與創造:爲什麼v1 web組件customElements.define()拋出TypeError
class App extends HTMLElement {
attachedCallback() {
this.attachShadow({mode: 'open'});
this.shadowRoot.innterHTML = `<div>web component</div>`
}
}
和
<x-app></x-app>
然而,在Chrome Canary版的最新版本,並與V1運行代碼時在Firefox中填充工具,下面的錯誤被拋出:
Uncaught TypeError: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
ES5考慮自定義元素:https://github.com/w3c/webcomponents/issues/423 –