CustomElementRegistry: get() Methode
Die get()
-Methode des
CustomElementRegistry
-Interfaces gibt den Konstruktor für ein zuvor definiertes benutzerdefiniertes Element zurück.
Syntax
js
get(name)
Parameter
name
-
Der Name des benutzerdefinierten Elements.
Rückgabewert
Der Konstruktor für das benannte benutzerdefinierte Element oder undefined
, wenn kein benutzerdefiniertes Element mit diesem Namen definiert ist.
Beispiele
js
customElements.define(
"my-paragraph",
class extends HTMLElement {
constructor() {
let templateContent = document.getElementById("custom-paragraph").content;
super() // returns element this scope
.attachShadow({ mode: "open" }) // sets AND returns this.shadowRoot
.append(templateContent.cloneNode(true));
}
},
);
// Return a reference to the my-paragraph constructor
let ctor = customElements.get("my-paragraph");
Spezifikationen
Specification |
---|
HTML # dom-customelementregistry-get-dev |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
get |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.