-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
54 lines (36 loc) · 1.23 KB
/
index.md
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
---
title: "CustomElementRegistry: upgrade() method"
short-title: upgrade()
slug: Web/API/CustomElementRegistry/upgrade
page-type: web-api-instance-method
browser-compat: api.CustomElementRegistry.upgrade
---
{{APIRef("Web Components")}}
The **`upgrade()`** method of the
{{domxref("CustomElementRegistry")}} interface upgrades all shadow-containing custom
elements in a {{domxref("Node")}} subtree, even before they are connected to the main
document.
## Syntax
```js-nolint
upgrade(root)
```
### Parameters
- `root`
- : A {{domxref("Node")}} instance with shadow-containing descendant elements to upgrade. If there are no descendant elements that can be upgraded, no error is
thrown.
### Return value
None ({{jsxref("undefined")}}).
## Examples
Taken from the [HTML spec](https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade):
```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!
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}