lit: undefined/null attribute gets rendered as 'undefined'
When rendering attributes, switching from a value to undefined causes ‘undefined’ to be set literally in the DOM.
This seems unexpected, how else do we let the renderer know that an attribute should no longer be set? See: http://jsbin.com/qigigavaqu/edit?html,output for a reproduction.
If you inspect the dom, you will first see <div foo="bar"></div>. After clicking the button, you wil see <div foo="undefined"></div>
The same behavior is observed when rendering a null attribute
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (9 by maintainers)
NodeParthas an undefined check that sets the value to emptystring if it is undefined or null:value = value == null ? '' : value;Currently
AttributePartdoes not have this check. I think for consistency, either bothNodePartandAttributePartshould have this behaviour, or none of them should.