You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an area of confusion and we don't have clear documentation on lit.dev relating to this case.
Initializing a boolean attribute to true results in confusing behavior, as you cannot declaratively remove the attribute that has been defaulted to true from markup.
AndrewJakubowicz
changed the title
Document that Boolean attributes should never be set to true.
Document that Boolean attributes should never be initialized to true.
Apr 6, 2022
AndrewJakubowicz
changed the title
Document that Boolean attributes should never be initialized to true.
Document that Boolean attributes should never be initialized to true if they should be configurable from markup
Apr 6, 2022
This just came up in a chat conversation today, as well. I think it's really more apropos to the Reactive properties section, because it's really about the attribute API of a given component. We don't really talk much about API patterns at the moment.
Context
This is an area of confusion and we don't have clear documentation on lit.dev relating to this case.
Initializing a boolean attribute to
true
results in confusing behavior, as you cannot declaratively remove the attribute that has been defaulted to true from markup.Proposal
Add a warning or note to https://lit.dev/docs/templates/expressions/#boolean-attribute-expressions stating that boolean attributes should never be default initialized to true.
References
This has been discussed in the past:
Out of scope of this issue, but maybe this can be caught by the analyzer.
The text was updated successfully, but these errors were encountered: