扩展 Chrome 中的内置元素时无法创建自定义元素 54
Unable to create custom element when extending built-in element in Chrome 54
从 Chrome 54 中的内置元素扩展时,我无法创建自定义元素。
据我所知,此功能有 shipped。有什么我想念的吗?也许 v1 规范的这一部分仍在不断变化。
<super-element>Super Element</super-element>
<button is="super-button">Super Button</button>
<script>
customElements.define('super-element', class extends HTMLElement {
constructor() {
super();
console.log('Super Element');
}
});
customElements.define('super-button', class extends HTMLButtonElement {
constructor() {
super();
console.log('Super Button');
}
}, {extends: 'button'});
</script>
// Output: Super Element
谢谢。
Perhaps this portion of the v1 spec is still in flux.
完全正确。
自定义内置 元素尚未在 Chrome 和 Opera HTML 渲染引擎 Blink 中实现。
查看 Chromium 项目跟踪器中的 "Launch" and "Implement" 错误。
另见 SO 回答 here for a workaround。
更新为 Chrome67
现在它适用于 Chrome 67 版及更高版本。
从 Chrome 54 中的内置元素扩展时,我无法创建自定义元素。
据我所知,此功能有 shipped。有什么我想念的吗?也许 v1 规范的这一部分仍在不断变化。
<super-element>Super Element</super-element>
<button is="super-button">Super Button</button>
<script>
customElements.define('super-element', class extends HTMLElement {
constructor() {
super();
console.log('Super Element');
}
});
customElements.define('super-button', class extends HTMLButtonElement {
constructor() {
super();
console.log('Super Button');
}
}, {extends: 'button'});
</script>
// Output: Super Element
谢谢。
Perhaps this portion of the v1 spec is still in flux.
完全正确。
自定义内置 元素尚未在 Chrome 和 Opera HTML 渲染引擎 Blink 中实现。
查看 Chromium 项目跟踪器中的 "Launch" and "Implement" 错误。
另见 SO 回答 here for a workaround。
更新为 Chrome67
现在它适用于 Chrome 67 版及更高版本。