Properties

Initial value

The initial value of a property can be declared in the props object:

class MyExample extends Wafer {
static get props() {
return {
count: {
type: Number,
initial: 10,
},
};
}
}

When an element is connected to the DOM (in the connectedCallback method), the initial value of a property is calculated as follows:

  1. If the property has already been set, this will be its initial value - i.e. any attribute or initial value will be ignored.
  2. If the property is unset (undefined) and an attribute with the same name as the property is present, the initial value will be set to the parsed value of the attribute using the property type rules. The initial value will not be used.
  3. If the property is unset (undefined) and there is no attribute with the same name, the initial value will be used, if present.
Next: Reflection Previous: Types