JavaScripture
Contribute via GitHub Feedback

JavaScript CustomElementPrototype : HTMLElement

The prototype used for a custom element created with customElements.define().

Instance Methods

adoptedCallback(oldDocument : Document, newDocument : Document) : undefined

Called when adopted into a new Document.

Example:

Run

Results:

 

attributeChangedCallback(name : String, oldValue : Object, newValue : Object, namespace : String) : undefined

Called when an attribute was changed on the element. See also MutationObserver.

Example:

Run

Results:

 

connectedCallback() : undefined

Called when the custom element is inserted into the document or when the prototype is applied to elements already in the tree at the time customElements.define() is called. See also MutationObserver.

Example:

Run

Results:

 

disconnectedCallback() : undefined

Called when the element is removed from the document. See also MutationObserver.

Example:

Run

Results:

 

Details

The following example demonstrates how to create a custom element based on HTMLElement.

Example:

Run

Results: