Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Somehow we are not enforcing prettier, allowing the button PR to slip through unprettified. Those changes are included in this PR.
Decorators is a stage 2 draft proposal. It allows decorating classes, properties and methods and enhance them. It has been included in TypeScript under an experimental flag.
Lit Element ships with a bunch of decorators that make writing elements even easier:
@customElement("hui-entity-button-card")
to register a class as a custom element.@property(options)
to register a field as a property. That way we don't have to define aproperties
method. (btw, we should only mark fields as properties if we want changing them to trigger a render)@query('.header')
or@queryAll('.card')
to turn a property into a getter that returns the results ofquerySelector
orquerySelectorAll
on the shadow root@observer((value, old) => { … })
. The observer method will be called whenever the value has changed and the DOM has been rendered (during theupdated
lifecycle).