Autonomous custom elements
The CustomElementRegistry interface provides methods for registering custom elements and querying registered elements. To get an instance of it, use the window.customElements property. To create a scoped registry, use the CustomElementRegistry() constructor.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 54 | 79 | 63 | 10 | 54 | 10 | |
| DOM API | ||||||
| The CustomElementRegistry interface provides methods for registering custom elements and querying registered elements. To get an instance of it, use the window.customElements property. To create a scoped registry, use the CustomElementRegistry.CustomElementRegistry() constructor. | 54 | 79 | 63 | 10.1 | 54 | 10.3 |
| 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. | 54 | 79 | 63 | 10.1 | 54 | 10.3 |
define (disabledFeatures static property) Supports `disabledFeatures` static property | 77 | 79 | 92 | | 77 | |
| The get() method of the CustomElementRegistry interface returns the constructor for a previously-defined custom element. | 54 | 79 | 63 | 10.1 | 54 | 10.3 |
| The getName() method of the CustomElementRegistry interface returns the name for a previously-defined custom element. | 117 | 117 | 116 | 17 | 117 | 17 |
| 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. | 68 | 79 | 63 | 12.1 | 68 | 12.2 |
| The whenDefined() method of the CustomElementRegistry interface returns a Promise that resolves when the named element is defined. | 54 | 79 | 63 | 10.1 | 54 | 10.3 |
| The customElements read-only property of the Window interface returns a reference to the global CustomElementRegistry object, which can be used to register new custom elements and get information about previously registered custom elements. | 54 | 79 | 63 | 10.1 | 54 | 10.3 |
- This browser only partially implements this feature
- Supports 'Autonomous custom elements' but not 'Customized built-in elements'. See bug 182671.
- This browser only partially implements this feature
- Supports 'Autonomous custom elements' but not 'Customized built-in elements'. See bug 182671.
- This browser only partially implements this feature
- Supports 'Autonomous custom elements' but not 'Customized built-in elements'.
- This browser only partially implements this feature
- Supports 'Autonomous custom elements' but not 'Customized built-in elements'.
Use cases
-
Using Autonomous custom elements
The CustomElementRegistry interface provides methods for registering custom elements and querying registered elements.
Cautions
- May not be supported in older browsers.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.