Ibyar/Aurora
    Preparing search index...

    Interface CustomElement

    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.

    interface CustomElement {
        adoptedCallback(): void;
        attributeChangedCallback(name: string, oldValue: any, newValue: any): void;
        connectedCallback(): void;
        connectedMoveCallback(): void;
        disconnectedCallback(): void;
    }

    Hierarchy (View Summary)

    Index
    • Called when attributes are changed, added, removed, or replaced. See Responding to attribute changes for more details about this callback.

      Parameters

      • name: string

        The name of the attribute which changed

      • oldValue: any

        The attribute's old value.

      • newValue: any

        The attribute's new value.

      Returns void

    • 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.

      Returns void