Web APIs

CustomElementRegistry.upgrade()

Try the free JavaScript compiler

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

NameTypeDescription
rootNodeSubtree 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);
JavaScript Reference