class
and style
are not formatted correctly when set inside object as x-bind="{ style: {...}, class: {...} }"
#4408
-
Came across what I believe is a bug: When I define HTML like so: <div x-data="{
data: {
style: {
color: 'red',
},
class: {
hidden: true,
},
},
}" x-bind="data">
bug
</div> Then the rendered HTML is <div
x-data="{
data: {
style: {
color: 'red',
},
class: {
hidden: true,
},
}
}"
x-bind="data"
style="[object Object]"
class="[object Object]"
>
bug
</div> The Instead of style="color: red;"
class="hidden" Basically, it looks like |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
The docs is not super clear but the object syntax is only supported when binding class and style directly (x-bind:class and x-bind:style). It may be possible to adjust the implementation to support it for the generic case but it needs to be added. |
Beta Was this translation helpful? Give feedback.
-
make your binding object keys be |
Beta Was this translation helpful? Give feedback.
make your binding object keys be
:style
and:class
instead, so that it invokes the directive handlers