Palette
    Preparing search index...

    Interface ComponentShorthand<StateShape>

    interface ComponentShorthand<StateShape extends object = {}> {
        afterUpdate?: (
            this: Component<StateShape>,
            previousAttributes?: Record<string, string | null>,
        ) => void;
        beforeUpdate?: (
            this: Component<StateShape>,
            changedAttributes?: Record<string, string | null>,
        ) => void;
        finalize?: (this: Component<StateShape>) => void;
        initialState?:
            | StateShape
            | State<StateShape>
            | (() => State<StateShape>)
            | (() => StateShape);
        observedAttributes?: string[];
        onError?: (this: Component<StateShape>, error: unknown) => void;
        rootMode?: RootMode;
        script?: (this: Component<StateShape>) => void | VoidFunction;
        style?: string | CSSStyleSheet | CSSStyleSheet[];
        template?: HTMLTemplateElement;
        computedProperties?(
            this: Component<StateShape>,
            attributes?: Record<string, string | null>,
            state?: StateShape,
        ): Record<string, unknown>;
    }

    Type Parameters

    • StateShape extends object = {}
    Index

    Properties

    afterUpdate?: (
        this: Component<StateShape>,
        previousAttributes?: Record<string, string | null>,
    ) => void

    Called immediately after each template update

    beforeUpdate?: (
        this: Component<StateShape>,
        changedAttributes?: Record<string, string | null>,
    ) => void

    Called immediately before each template update

    finalize?: (this: Component<StateShape>) => void

    Called as the final lifecycle method at the end of the unmounting process.

    initialState?:
        | StateShape
        | State<StateShape>
        | (() => State<StateShape>)
        | (() => StateShape)

    The initial state for this Component

    observedAttributes?: string[]

    Attributes to watch for changes for updates.

    onError?: (this: Component<StateShape>, error: unknown) => void

    If defined, receives errors caught during the lifecycle methods of this component and it's children. If not defined, this component will instead throw errors as they are found.

    rootMode?: RootMode

    The mode for this Component's ShadowRoot.

    MDN: https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/mode

    script?: (this: Component<StateShape>) => void | VoidFunction

    Initialization scripting for this Component

    style?: string | CSSStyleSheet | CSSStyleSheet[]

    Styles to encapsulate to this component's root.

    template?: HTMLTemplateElement

    An HTML Template element for this element to use.

    Methods

    • An object or function returning an object which populates the data values in the templating engine. Such values are accessed using the * notation.

      Parameters

      Returns Record<string, unknown>