DOM Methods
CustomElementRegistry.get()
Looks up a registered constructor by name. Returns undefined for an unregistered name; use whenDefined when a later registration must be awaited. Example result: true.
Formal Syntax & Structure
html syntaxhtml
customElements.get(name)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Custom element name. |
Return Value
CustomElementConstructor | undefined
Registered constructor or undefined.
Working Example
Example Snippethtml
<p> Result: <output id="result"></output></p><script> const result = document.getElementById("result"); (async () => { class DemoCard extends HTMLElement {} customElements.define("demo-card", DemoCard); result.textContent = customElements.get("demo-card") === DemoCard; })().catch(error => { result.textContent = "Error: " + error.name; });</script>