aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/api/customelementregistry/upgrade/index.html
blob: 203e4120b967bf2b01118c935f67258e6a0d3ea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: CustomElementRegistry.upgrade()
slug: Web/API/CustomElementRegistry/upgrade
tags:
    - API
    - CustomElementRegistry
    - Method
    - Reference
    - Upgrade
    - Web Components
    - custom elements
browser-compat: api.CustomElementRegistry.upgrade
---

<p>{{APIRef("CustomElementRegistry")}}</p>
<p>
    O <code><strong>upgrade()</strong></code> é um método de {{domxref("CustomElementRegistry")}} a interface atualiza todos os shadow-containing custom elements em um {{domxref("Node")}} da
    subárvore, mesmo antes de estarem conectados ao principal documento.
</p>

<h2 id="Syntax">Syntax</h2>

<pre class="brush: js">
customElements.upgrade(<em>root</em>);
</pre>

<h3 id="Parameters">Parâmetros</h3>

<dl>
    <dt><code>root</code></dt>
    <dd>
        Uma instância de {{domxref("Node")}} com shadow-containing os elementos descendentes que serão atualizados. Se não houver elementos descendentes que possam ser atualizados, nenhum erro será
        emitido.
    </dd>
</dl>

<h3 id="Return_value">Valor de retorno</h3>

<p>Void.</p>

<h2 id="Examples">Exemplos</h2>

<p>Retirado de <a href="https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade">HTML spec</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)); // Ainda não atualizado

customElements.upgrade(el);
console.assert(el instanceof SpiderMan);    // Atualizado!
</pre>

<h2 id="Specifications">Especificações</h2>

{{Specifications}}

<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>

<p>{{Compat}}</p>