aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/customelementregistry/upgrade
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/customelementregistry/upgrade
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/customelementregistry/upgrade')
-rw-r--r--files/zh-cn/web/api/customelementregistry/upgrade/index.html64
1 files changed, 64 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/customelementregistry/upgrade/index.html b/files/zh-cn/web/api/customelementregistry/upgrade/index.html
new file mode 100644
index 0000000000..412485c9d6
--- /dev/null
+++ b/files/zh-cn/web/api/customelementregistry/upgrade/index.html
@@ -0,0 +1,64 @@
+---
+title: CustomElementRegistry.upgrade()
+slug: Web/API/CustomElementRegistry/upgrade
+translation_of: Web/API/CustomElementRegistry/upgrade
+---
+<p>{{APIRef("CustomElementRegistry")}}</p>
+
+<p>CustomElementRegistry接口的upgrade()方法将更新节点子树中所有包含阴影的自定义元素,甚至在它们连接到主文档之前也是如此。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">customElements.upgrade(<em>root</em>);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>root</code></dt>
+ <dd>待升级的包含阴影的派生元素<code>节点</code> 。如果没有可升级的派生实例,则不会抛出异常。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>空.</p>
+
+<h2 id="示例">示例</h2>
+
+<p>摘至<a href="https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade">HTML 规范</a>:</p>
+
+<pre class="brush: 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!
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName("HTML WHATWG", "custom-elements.html#dom-customelementregistry-upgrade", "customElements.upgrade()")}}</td>
+ <td>{{Spec2("HTML WHATWG")}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器支持">浏览器支持</h2>
+
+<div>
+
+
+<p>{{Compat("api.CustomElementRegistry.upgrade")}}</p>
+</div>