CustomElementRegistry: get() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The get() method of the CustomElementRegistry interface returns the constructor for a previously-defined custom element.

Syntax

js
get(name)

Parameters

name

The name of the custom element.

Return value

The constructor for the named custom element, or undefined if there is no custom element defined with the name.

Examples

js
customElements.define(
  "my-paragraph",
  class extends HTMLElement {
    constructor() {
      const template = document.getElementById("custom-paragraph");
      super() // returns element this scope
        .attachShadow({ mode: "open" }) // sets AND returns this.shadowRoot
        .append(document.importNode(template.content, true));
    }
  },
);

// Return a reference to the my-paragraph constructor
const ctor = customElements.get("my-paragraph");

Specifications

Specification
HTML
# dom-customelementregistry-get-dev

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
get
Chrome – Full support
Chrome 54 (Release date: 2016-10-12)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 63 (Release date: 2018-10-23)
footnote Full support
Opera – Full support
Opera 41 (Release date: 2016-10-25)
footnote Full support
Safari – Partial support
Safari 10.1 (Release date: 2017-03-27)
footnote Partial support
footnote Supports 'Autonomous custom elements' but not 'Customized built-in elements'. See bug 182671.
Chrome Android – Full support
Chrome Android 54 (Release date: 2016-10-19)
footnote Full support
Firefox for Android – Full support
Firefox for Android 63 (Release date: 2018-10-23)
footnote Full support
Opera Android – Full support
Opera Android 41 (Release date: 2016-10-25)
footnote Full support
Safari on iOS – Partial support
Safari on iOS 10.3 (Release date: 2017-03-27)
footnote Partial support
footnote Supports 'Autonomous custom elements' but not 'Customized built-in elements'. See bug 182671.
Samsung Internet – Full support
Samsung Internet 6 (Release date: 2017-08-23)
footnote Full support
WebView Android – Full support
WebView Android 54 (Release date: 2016-10-19)
footnote Full support
WebView on iOS – Partial support
WebView on iOS 10.3 (Release date: 2017-03-27)
footnote Partial support
footnote Supports 'Autonomous custom elements' but not 'Customized built-in elements'. See bug 182671.

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support