Skip to content

Document that Boolean attributes should never be initialized to true if they should be configurable from markup #744

@AndrewJakubowicz

Description

@AndrewJakubowicz

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions