Description
When binding attributes to an HTML element using component properties and the lwc:spread directive, null or undefined values are handled inconsistently.
-
When set via a standard component property, attributes with null or undefined values are removed from the element.
-
When set via lwc:spread, those same values are rendered as the string "null" or "undefined".
Steps to Reproduce
-
Open the playground link
-
Observe a element with the following attributes:
-
Click the button to set both id and lang to null.
Expected Results
All attributes bound to null or undefined, regardless of binding method, should be removed from the DOM.
Specifically to the demo, both id and lang should be removed from the button element.
Actual Results
id is correctly removed.
lang remains on the element and is set to the string "null".
Browsers Affected
All.
Version