-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Svelte5: Inconsistent DOM Update Behavior between Svelte 4 and Svelte 5 using sveltekit2 #10332
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
Comments
After some more testing, I figured out that using the svelte4 version of the code in an app that uses svelte5 (although it should behave the same with no changes) the same bug happens. So I think it is something about svelte5 in general. |
After even some more testing, this doesn't work also, this is so weird and so fundamental to svelte usage:
server-side rendered |
Svelte 5 assumes that the array doesn't change between server and client; we should probably add a check during hydration that the length stayed the same. |
@dummdidumm So, this means we can't make a new object from the server's array of I believe we should be able to modify the initial list of items given by the server on the client side (using localStorage, requests from the client side, user interactions (clicking delete btn etc). take this as an example:
I also want to point out that changing things this way won't alter the original |
Describe the bug
Lets try to rewrite this svelte 4 code to svelte 5:
--svelte 4
--svelte5
Expected Behavior
: The expected outcome is identical to the Svelte 4 version: initially displaying two `h1` elements with 'test-server' and 'test-server2', then dynamically updating the DOM to only show 'test-client' when the JavaScript loads and runs. This behavior is consistent in a Svelte 4 app (refer to tests-svelte4 and run it).Actual Behavior in Svelte 5
: In the Svelte 5 version, the behavior differs unexpectedly. While it updates 'test-server' to 'test-client', it fails to remove 'test-server2' from the DOM.I've created a reproduction repo here.
Reproduction
props
instead ofexport data
to fail** even using the svelte4 version in an app that uses svelte5, it fails**
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: