WebReflection / hyperHTML

A Fast & Light Virtual DOM Alternative
ISC License
3.06k stars 112 forks source link

Discrepancy on how Boolean attributes are handled #331

Closed atirip closed 5 years ago

atirip commented 5 years ago

This:

    hyperHTML.bind(document.body)`
    <button disabled=${false} data-foo=${false} data-bar=${undefined} data-blaah=${null}>
        click me if you can
    </button>`;

renders into this:

    <button data-foo="false">
        click me if you can
    </button>

https://codepen.io/anon/pen/OroBEG?editors=0010

WebReflection commented 5 years ago

yes, it's OK, that's how it's always been. null and undefined are used to remove attributes or handlers, false can be used only on boolean attributes, such as checked, disabled, and others. If the attribute has no special meaning, false is set as string, same as 0, or empty strings.

WebReflection commented 5 years ago

P.S. this was also described in the documentation https://viperhtml.js.org/hyperhtml/documentation/#essentials-4

atirip commented 5 years ago

Yes, thanks, now I see it :-)