-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
undefined and false in css variables in inline styles are not removed #5322
Comments
Hey @hit12369 Can I do this please? |
This seems to be just how CSS variables work: $0.style.setProperty('--color', undefined) // sets the string undefined |
While it is true, setting it as undefined removes the property in vue 2. vue2 example: https://jsfiddle.net/zb1x79m0/ Also it would ensure consistency with non variable css properties. $0.style.color = 'red'
$0.style.color = undefined // color does not change, but if we use :style="{color: undefined}" in vue, color gets removed Example playground link: sfc.vuejs.org |
Seems we indeed have an inconsistency here. the code responsible for remoiving style properties relies on _createElementVNode("h1", {
style: _normalizeStyle({color: x.value })
}, " color ", 4 /* STYLE */), but normalizeStyle isn't being used when we have a plain object not using variables: _createElementVNode("h1", {
style: {color: undefined }
}, " color "), (Compiled code snippets taken from @hit12369 's sfc playground in their latest comment). |
There's a problem even with Playground link: sfc.vuejs.org |
sound like use empty string I would have said, just remove the style from the object, but that will actually not work for reactive object, without cloning/spreading |
Version
3.2.29
Reproduction link
sfc.vuejs.org/
Steps to reproduce
Use
:style="{'--var': undefined}"
or:style="{'--var': false}"
in a template.It's rendered as
style="--var: undefined"
orstyle="--var: false"
which seems incorrect,--var
should be removed instead. Usingnull
works correctly and--var
is removed.What is expected?
Inline css variable should be removed.
What is actually happening?
It's actually being rendered as undefined.
The text was updated successfully, but these errors were encountered: