Called each time the element is moved to a new document.
Called when attributes are changed, added, removed, or replaced. See Responding to attribute changes for more details about this callback.
The name of the attribute which changed
The attribute's old value.
The attribute's new value.
Called each time the element is added to the document. The specification recommends that, as far as possible, developers should implement custom element setup in this callback rather than the constructor.
When defined, this is called instead of () and () each time the element is moved to a different place in the DOM via (). Use this to avoid running initialization/cleanup code in the () and () callbacks when the element is not actually being added to or removed from the DOM. See Lifecycle callbacks and state-preserving moves for more details.
Called each time the element is removed from the document.
Custom Elements
One of the key features of web components is the ability to create custom elements: that is, HTML elements whose behavior is defined by the web developer, that extend the set of elements available in the browser. This article introduces custom elements, and walks through some examples.
There are two types of custom element:
Autonomous custom elements inherit from the HTML element base class HTMLElement. You have to implement their behavior from scratch.
Customized built-in elements inherit from standard HTML elements such as HTMLImageElement or HTMLParagraphElement. Their implementation extends the behavior of select instances of the standard element.