-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Spread is not consistent with attribute for style #15309
Comments
Note : for custom-element the difference come from the |
What is the difference I'm supposed to be seeing (and in which browser, if that makes a difference)? |
The only difference is the value of the With spreading, the style attribute is processed by the browser and reformated :
And I think it's evaluated again on hydration. Tested on Chrome & Firefox |
Thanks for clarifying. |
It's not a big deal and there not difference on render. Example in DOM inspector : I also think that the style may be processed twice on page loading, because the value is re-set via I just see that writing a test for the PR #15311 |
I make a demo on sveltelabs for hydration : https://www.sveltelab.dev/7c65e2chz1msknn On the layout I create an observer to logs mutations.
Note that the |
Describe the bug
I just found that spreading the
style
attribute have a different result from setting it directlyThese two lines are not equivalent on client-side (server-side is OK) :
=> That's because the attribute
style
is set viaelement.setAttribute()
, but with spreads it set viastyle.cssText
svelte/packages/svelte/src/internal/client/dom/elements/attributes.js
Lines 378 to 380 in c40392c
I think that this line could fix the problem :
Reproduction
https://svelte.dev/playground/hello-world?version=5.20.1#H4sIAAAAAAAACm2RUU_CMBDHv0pTH4AEhiY-dXOJURJNRB9EXxgPXXcjC127tDeEkH1322YEEXIv7e_-979e70AVr4Ey-gJSavKjjSzIEIoKoRjRMS0rCZay5YHivvE6Dxzvqx6bJrJbkOhZzi1c40IrBIXOhiZWmKrBNFMZSkBicS-BPJBBzc26Uuy-2cU5F5u10a0q2E155yMWQrDbWGipDVsbANWfc9nCIM5UMj35qufXb8IcK6otOYQGXZpM3S09wiiK-sQpk6mnr8_Fx3wye5vNZ--LYCFai7qegITaDfDH7TyRXpGe97jQ-0hCPvzF_2rPMiwq20i-ZySXWmxiD7tL9TLYrBjjJYIZe4Eb6ZweHftVMMIRzTBIRkdf94nhPW5jCDukDE0L3ar7BYgUaukjAgAA
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: