web api interface
CustomElementRegistry
The CustomElementRegistry interface provides methods for registering custom elements and querying registered elements. To get an instance of it, use the customElements property. To create a scoped registry, use the CustomElementRegistry() constructor.
Constructor
CustomElementRegistry()- : Creates a new
CustomElementRegistryobject, for scoped usage.
- : Creates a new
Instance methods
define()- : Defines a new custom element.
get()- : Returns the constructor for the named custom element, or
undefinedif the custom element is not defined.
- : Returns the constructor for the named custom element, or
getName()- : Returns the name for the already-defined custom element, or
nullif the custom element is not defined.
- : Returns the name for the already-defined custom element, or
upgrade()- : Upgrades a custom element directly, even before it is connected to its shadow root.
initialize()- : Associates a scoped registry with a DOM subtree, setting the custom element registry on each inclusive descendant and upgrading any custom elements.
whenDefined()- : Returns an empty
Promisethat resolves when a custom element becomes defined with the given name. If such a custom element is already defined, the returned promise is immediately fulfilled.
- : Returns an empty
Examples
See the Examples section in our guide to using custom elements.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.