W3cubDocs

/DOM

CustomElementRegistry

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

Feature Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 541 No2 Yes3 No 411 10.11
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.

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry