kenchris / lit-element

A base class for creating web components using lit-html
BSD 3-Clause "New" or "Revised" License
81 stars 10 forks source link

Provide example for bound Boolean properties & attributes #4

Closed klebba closed 6 years ago

klebba commented 6 years ago

Example:

<my-element foo="${bar}"></my-element>

When foo has a property definition with type Boolean, Polymer would render this binding as:

<my-element foo></my-element>

When bar is truthy. Otherwise foo is removed. This is a necessary behavior for CSS selectors like:

<style>
:host([foo]) {
    color: red;
}
</style>
kenchris commented 6 years ago

Yes, I should fix that.

The following would be correct <div foo> or <div foo=""> or <div foo="foo"> or case-insensitive and single quotes/unquoted variations.