Scoped custom element registries
The CustomElementRegistry() constructor creates a new CustomElementRegistry object for scoped usage.
The constructor is specifically used for creating scoped registries that limit custom element definitions to a particular scope, such as an element or ShadowRoot.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 146 | 146 | | 26 | 146 | 26 | |
| The initialize() method of the CustomElementRegistry interface associates this registry with a DOM subtree, setting the Element.customElementRegistry of each inclusive descendant that doesn't already have one, and attempting to upgrade any custom elements found. | 146 | 146 | | 26 | 146 | 26 |
| The customElementRegistry read-only property of the Document interface returns the CustomElementRegistry object associated with this document, or null if one has not been set. | 146 | 146 | 150 | 26 | 146 | 26 |
| The customElementRegistry read-only property of the Element interface returns the CustomElementRegistry object associated with this element, or null if one has not been set. | 146 | 146 | 150 | 26 | 146 | 26 |
| The shadowRootCustomElementRegistry property of the HTMLTemplateElement interface reflects the value of the shadowrootcustomelementregistry attribute of the associated element. | 146 | 146 | | 26 | 146 | 26 |
| The customElementRegistry read-only property of the ShadowRoot interface returns the CustomElementRegistry object associated with this shadow root, or null if one has not been set. | 146 | 146 | 150 | 26 | 146 | 26 |
- Requires an experimental browser flag to be enabled
- Requires an experimental browser flag to be enabled
- Requires an experimental browser flag to be enabled
Syntax
new CustomElementRegistry() Use cases
-
Using Scoped custom element registries
The CustomElementRegistry() constructor creates a new CustomElementRegistry object for scoped usage.
Cautions
- Limited browser support. Check compatibility before use.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.