Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. CustomElementRegistry
  4. upgrade()

CustomElementRegistry: upgrade() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Theupgrade() method of theCustomElementRegistry interface upgrades all shadow-containing customelements in aNode subtree, even before they are connected to the maindocument.

Syntax

js
upgrade(root)

Parameters

root

ANode instance with shadow-containing descendant elements to upgrade. If there are no descendant elements that can be upgraded, no error isthrown.

Return value

None (undefined).

Examples

Taken from theHTML spec:

js
const el = document.createElement("spider-man");class SpiderMan extends HTMLElement {}customElements.define("spider-man", SpiderMan);console.assert(!(el instanceof SpiderMan)); // not yet upgradedcustomElements.upgrade(el);console.assert(el instanceof SpiderMan); // upgraded!

Specifications

Specification
HTML
# dom-customelementregistry-upgrade-dev

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp