Skip to content
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

Non consistent reactivity with style:value / undefined and empty string #8462

Closed
dm-de opened this issue Apr 7, 2023 · 2 comments · Fixed by #8517
Closed

Non consistent reactivity with style:value / undefined and empty string #8462

dm-de opened this issue Apr 7, 2023 · 2 comments · Fixed by #8517

Comments

@dm-de
Copy link

dm-de commented Apr 7, 2023

Describe the bug

style:value works different, if you set empty string or undefined.
Once a style-value is set, it can no more removed with undefined!
But empty string can remove value.
see example in reproduction

<div style:font-family={undefined}>div 1</div>
<div style:background={undefined}>div 2</div>
<div style:font-family={''}>div 3</div>
<div style:background={''}>div 4</div>

note that style:font-family generate this wrong code:
<div style="font-family: undefined;">div 1</div>
here are possible other style-values that can generate wrong code (?)

Reproduction

https://svelte.dev/repl/21ee1c2341fe44e9ae2b9994fcd99253?version=3.58.0

Resize html result.
Left side of "content" should change.
But once it moves, it never returns back.

at line:
style:left={left_ ? left_ + 'px' : undefined}
replace undefined with ''
now it works like expected

Logs

No response

System Info

svelte 3.58.0
vite

Severity

annoyance

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Apr 7, 2023

#7580
#7446

dummdidumm added a commit that referenced this issue Apr 19, 2023
fixes #8462

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
@Conduitry
Copy link
Member

This has been fixed in 3.59.0 - https://svelte.dev/repl/21ee1c2341fe44e9ae2b9994fcd99253?version=3.59.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants