CustomElementRegistry: upgrade()-Methode
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since Januar 2020.
Die upgrade()-Methode der CustomElementRegistry-Schnittstelle aktualisiert alle Schatten-inhaltigen benutzerdefinierten Elemente in einem Node-Teilbaum, selbst bevor sie mit dem Hauptdokument verbunden sind.
Syntax
js
upgrade(root) Parameter
Rückgabewert
Keiner (undefined).
Beispiele
Entnommen aus der HTML Spezifikation:
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! Spezifikationen
| Specification |
|---|
| HTML> # dom-customelementregistry-upgrade-dev> |