The current implementation can be greatly improved:
There is an unnecessary input property, dateStr, that accepts a string.
The code around willUpdate is a bit messy and imperative.
If the user sets date to a new date, the dateStr will not be updated.
The root cause of these issues is that Lit does not have a default converter that converts a string to a Date object. This is where custom attribute converters come in! A custom attribute converter can clean up the implementation of date-display by providing a means to convert a string attribute to a Date object property.
In this step, you'll define a custom attribute converter that can convert a date-string attribute into a Javascript Date object property and back again.