CustomElementRegistry.upgrade()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
CustomElementRegistry 接口的 upgrade() 方法将更新节点子树中所有包含阴影的自定义元素,甚至在它们连接到主文档之前也是如此。
语法
customElements.upgrade(root);
参数
root
-
待升级的包含阴影的派生元素
节点
。如果没有可升级的派生实例,则不会抛出异常。
返回值
空。
示例
摘至HTML 规范:
js
const el = document.createElement("spider-man");
class SpiderMan extends HTMLElement {}
customElements.define("spider-man", SpiderMan);
console.assert(!(el instanceof SpiderMan)); // not yet upgraded
customElements.upgrade(el);
console.assert(el instanceof SpiderMan); // upgraded!
规范
Specification |
---|
HTML # dom-customelementregistry-upgrade-dev |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
upgrade |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.