CustomElementRegistry
The CustomElementRegistry interface provides methods for registering custom elements and querying registered elements. To get an instance of it, use the window.customElements property.
Methods
define()
define(
name,
constructor,
options?
): void;
The define() method of the CustomElementRegistry interface adds a definition for a custom element to the custom element registry, mapping its name to the constructor which will be used to create it.
Parameters
| Parameter | Type |
|---|---|
name | string |
constructor | CustomElementConstructor |
options? | ElementDefinitionOptions |
Returns
void
get()
get(name): CustomElementConstructor | undefined;
The get() method of the CustomElementRegistry interface returns the constructor for a previously-defined custom element.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
CustomElementConstructor | undefined
getName()
getName(constructor): string | null;
The getName() method of the CustomElementRegistry interface returns the name for a previously-defined custom element.
Parameters
| Parameter | Type |
|---|---|
constructor | CustomElementConstructor |
Returns
string | null
initialize()
initialize(root): void;
Parameters
| Parameter | Type |
|---|---|
root | Node |
Returns
void
upgrade()
upgrade(root): void;
The upgrade() method of the CustomElementRegistry interface upgrades all shadow-containing custom elements in a Node subtree, even before they are connected to the main document.
Parameters
| Parameter | Type |
|---|---|
root | Node |
Returns
void
whenDefined()
whenDefined(name): Promise<CustomElementConstructor>;
The whenDefined() method of the CustomElementRegistry interface returns a Promise that resolves when the named element is defined.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
Promise<CustomElementConstructor>