Lit has built-in attribute converters for basic types like number and boolean. In this step and the following one, you'll use a built-in attribute converter and some imperative code to set the date property from markup.
In this step, you start with a Lit component that:
Has a date reactive property of type Date.
Has attribute to property conversion turned off {attribute: false}.
Displays the date in a human-readable format.
The date property is set in index.html, using JavaScript. The date property can't be set from an attribute, because Lit doesn't have a built-in attribute converter to convert a string date to a Date object.
Attribute converters tell Lit how to convert an attribute to a property and, in the case that a reactive property has the reflect: true flag, from property to attribute.
Lit has several built-in attribute converters. You can choose which built-in converter is invoked by setting the type option when you declare a reactive property. The built-in converters are:
In this step, you'll add a new dateStr reactive property that accepts a human-readable date string, and can be set from an attribute. (That is, date-str="05/05/22".)
Now setting the date-str attribute to 05/05/22 will update the dateStr property to 05/05/22 because the built-in String attribute converter is used! Unfortunately, you won't see any change to the output, because the date property isn't being updated.