Web APIs
CustomElementRegistry.prototype.whenDefined()
Resolves to the registered constructor once the valid name is defined.
Formal Syntax & Structure
javascript syntaxjavascript
customElements.whenDefined(name)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Valid custom element name. |
Return Value
Promise<CustomElementConstructor>
Resolves to the registered constructor once the valid name is defined.
Working Example
Example Snippetjavascript
(async () => {const waiting=customElements.whenDefined("lesson-chip");class LessonChip extends HTMLElement{};customElements.define("lesson-chip",LessonChip);console.log((await waiting)===customElements.get("lesson-chip"));})()