-
-
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
fix(shared): normalize undefined styles to empty object #4424
Conversation
b8dcceb
to
0b3743a
Compare
@yyx990803 Thanks for the review. I made the requested changes. |
Thank you for the PR. Can you make a minimal reproduction for the issue you are trying to fix? I tried to make a repro but it does work as expected ( And according to the coercion behavior for Vue 3, |
@Justineo I spent some time in the SFC playground today, trying to get a reproduction working (not working?). I don't really have any more time to spend on setting trying to reproduce the issue. We fixed it in the library by using an empty object instead of undefined. I'm okay with closing this issue. Thanks for your help.
This is really interesting to know, thanks. For what it's worth, I was getting an empty style, as opposed to the attribute being removed: |
I was able to reproduce this: link (Clicking "remove" should not cause the input to be shown) |
After looking into it I believe the more proper fix is ensuring style patching always respect |
@yyx990803 Thanks for the help with diagnosing this. When you create the patch for that, will you link to it here? I'm interested in seeing where that happens. Thanks! |
Currently, setting
v-bind:style
to a value that can compute to undefined will remove any styles on the element when it does return undefined. I ran into this issue when usingv-show
along with anundefined
style binding.This patch makes it so that the
normalizeStyle
function will convert undefined/null bindings to an empty object instead. I feel like this is a good place to add the check, but it is my first patch on this repo. If anyone can think of a better place to do this, I will change it.