jj
    Preparing search index...

    Function attr2prop

    • A helper to bridge the attribute world (kebab-case) to the property world (camelCase). It works in tandem with browser's observedAttributes feature which triggers attributeChangedCallback.

      Parameters

      • instance: HTMLElement

        A reference to the common component instance

      • name: string

        kebab-case and in lower case exactly as it appears in observedAttributes.

      • oldValue: unknown

        The previous value of the attribute.

      • newValue: unknown

        The new value of the attribute.

      Returns boolean

      true if it tried to set the attribute; otherwise false.

      Your custom component class MUST define static observedAttributes[] otherwise attributeChangedCallback won't trigger. observedAttributes should contain kebab-based attribute names.

      if the instance is not an HTMLElement or if the property corresponding to the attribute does not exist on the instance.

      if setting the property throws an error for any reason.