tbranyen/diffhtml

When passing a single attribute default to boolean for components

tbranyen opened this issue · 3 comments

function render() {
  return html`<${SomeComponent} checked />`;
}

This should be checked=true for property and checked=checked for the attribute.

I'm curious why you want to force XML semantics here. I noticed the current tests don't use hasAttribute for Booleans but it does pass if those assertions are added.

<div itemscope> This is valid HTML but invalid XML. </div>
<div itemscope=itemscope> This is also valid HTML but invalid XML. </div>
<div itemscope=""> This is valid HTML and also valid XML. </div>
<div itemscope="itemscope"> This is also valid HTML and XML, but perhaps a bit verbose. </div>

In this case it's more about aligning closer to how React works rather than XML/HTML semantics. As component code I'd expect this to produce checked=checked as an attribute and checked=true as a property. checked: 'checked' is a less useful prop value for a component is why I'd prefer a boolean there.

Closed this in c46c6ab if you're interested in checking it out.