The define()
method of the CustomElementRegistry
interface defines a new custom element.
This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
customElements.define(name,constructor,options);
extends
. String specifying the name of a built-in element to extend. Used to create a customized built-in element.Void.
class BasicElement extends HTMLElement { connectedCallback() { this.textContent = 'Just a basic custom element.'; } } customElements.define('basic-element', BasicElement);
<basic-element><basic-element>
Feature | Firefox (Gecko) | Chrome | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | ? | 54 | No support | 41 | WebKit nightly |
Customized built-in elements | ? | 54 | No support | 41 | No support |
Feature | Firefox Mobile (Gecko) | Chrome for Android | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | 54 | No support | 41 | No support |
Customized built-in elements | ? | 54 | No support | 41 | No support |
© 2005–2017 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/define