Interface AttrOptions<Type, TypeHint>

    interface AttrOptions<Type = unknown, TypeHint = unknown> {
        attribute?: string;
        converter?: ComplexAttributeConverter<Type, TypeHint>;
        reflect?: boolean;
        type: TypeHint;
    }

    Type Parameters

    • Type = unknown
    • TypeHint = unknown
    Index

    Properties

    attribute?: string

    Indicates the name of the observed attribute. If absent, the lowercased property name is observed (e.g. fooBar becomes foobar). If a string, the string value is observed (e.g attribute: 'foo-bar').

    Indicates how to convert the attribute to/from a property. If this value is a function, it is used to convert the attribute value a the property value. If it's an object, it can have keys for fromAttribute and toAttribute. If no toAttribute function is provided and reflect is set to true, the property value is set directly to the attribute. A default converter is used if none is provided; it supports Boolean, String, Number, Object, and Array. Note, when a property changes and the converter is used to update the attribute, the property is never updated again as a result of the attribute changing, and vice versa.

    reflect?: boolean

    Indicates if the property should reflect to an attribute. If true, when the property is set, the attribute is set using the attribute name determined according to the rules for the attribute property option and the value of the property converted using the rules from the converter property option.

    type: TypeHint

    Indicates the type of the property. This is used only as a hint for the converter to determine how to convert the attribute to/from a property.