Draft
This page is not complete.
The CustomElementRegistry
interface provides methods for registering custom elements and querying registered elements. It can be accessed with window.customElements
.
This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Methods
CustomElementRegistry.define()
- Defines a new custom element.
CustomElementRegistry.get()
- Returns the constuctor for the named custom element, or
undefined
if the custom element is not defined. CustomElementRegistry.whenDefined()
- Returns a
promise
that will be fulfilled when a custom element becomes defined with the given name. (If such a custom element is already defined, the returned promise is immediately fulfilled.)
Examples
// `window.customElements` is an instance of `CustomElementRegistry` window.customElements instanceof CustomElementRegistry // true
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'CustomElementRegistry' in that specification. |
Living Standard | Initial definition. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | 561 | 611 | No2 | ? | No | No | 10.11 |
1. Supports 'Autonomous custom elements' but not 'Customized built-in elements'
2. Under consideration
3. This feature is behind the dom.webcomponents.enabled
preference (needs to be set to true
). To change preferences in Firefox, visit about:config.