Properties

Attributes

Attributes are the name/value pairs that appear on HTML elements, with the value always being a string:

<div id="test">
<my-example firstname="Ada"></my-example>
</div>

Traditionally attributes and properties on built-in elements have no fixed relationship and the exact behaviour depends on the HTML element. Wafer takes a more consistent approach:

class MyExample extends Wafer() {
static get props() {
return {
surname: {
type: String,
reflect: true,
},
firstname: {
type: String,
reflect: true,
attributeName: "first-name",
},
};
}
}

Here the surname property is reflected to a surname attribute, while the firstname property is reflected to a first-name attribute.

Next: Events Previous: Triggers