Open nolanlawson opened 3 months ago
For context, this behavior is by design. I recall having a dev sync discussion where the outcome was to keep it as simple as possible and to avoid any special handling.
The documentation could be better--it feels like we could add more detail around event handlers and IDL attributes that reflect as content attributes.
Description
lwc:spread
applies property names to an element (similar toObject.assign()
), but not attributes, which may be unexpected.For example, a developer might assume that this will render as
class="red"
:However, it does not. Instead, you must use
className
:Similarly, you cannot apply attributes that do not have a property equivalent:
Steps to Reproduce
See repro
Potential workaround
Use the property format (e.g.
className
instead ofclass
), or userenderedCallback
to manually callsetAttribute()
on the element.Potential solution
This would be an overhaul of how
lwc:spread
currently works and would have the potential for backwards-incompatible breakages. For the time being, though, this issue can at least serve as documentation about the current behavior.