Web APIs
CustomElementRegistry.upgrade()
Attempt to upgrade eligible elements in a subtree, including a detached subtree, using definitions in the registry. Example console output: true.
Formal Syntax & Structure
javascript syntaxjavascript
customElements.upgrade(root)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| root | Node | Subtree to upgrade. |
Return Value
undefined
No result value.
Working Example
Example Snippetjavascript
const root=document.createElement("div"); root.append(document.createElement("lesson-card")); class LessonCard extends HTMLElement{} customElements.define("lesson-card",LessonCard); customElements.upgrade(root); console.log(root.firstChild instanceof LessonCard);