You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When hydrating a server-side-rendered page, Svelte applies numerous unexpected mutations—mainly removing and adding empty text nodes. The number of mutations seems to grow linearly with the number of components.
The expected behavior is to observe no mutations, unless something has changed. Please note that the issue I am describing is observed in production build, not only in development (where some mutations are justified).
Reproduction
To reproduce, one can just add a MutationObserver to app.html:
<bodydata-sveltekit-preload-data="hover"><divstyle="display: contents" id="kit-body">%sveltekit.body%</div></body><script>// Callback function to execute when mutations are observedconstcallback=(mutationList,observer)=>{for(constmutationofmutationList){console.log(mutation);}};// Create an observer instance linked to the callback functionconstobserver=newMutationObserver(callback);// Start observing the target node for configured mutationsobserver.observe(document.getElementById('kit-body'),{attributes: true,childList: true,subtree: true,attributeOldValue: true});</script>
Reproduction in github repo (contains SvelteKit skeleton, with mutation observer in app.html)
Performing DOM manipulations on load can have unpleasant side effects. I discovered the issue while trying to figure out, why CSS animation on a server-rendered element was being reset during hydration.
The text was updated successfully, but these errors were encountered:
The are no more hydration mutations in the example in Svelte 5. The two that are left are from the announcer that is inserted on mount. Therefore closing.
Describe the bug
When hydrating a server-side-rendered page, Svelte applies numerous unexpected mutations—mainly removing and adding empty text nodes. The number of mutations seems to grow linearly with the number of components.
Here, for example, mutation logs from a bare-bone https://node.new/sveltekit project:
The expected behavior is to observe no mutations, unless something has changed. Please note that the issue I am describing is observed in production build, not only in development (where some mutations are justified).
Reproduction
To reproduce, one can just add a
MutationObserver
to app.html:Reproduction in github repo (contains SvelteKit skeleton, with mutation observer in app.html)
Logs
No response
System Info
Severity
Performing DOM manipulations on load can have unpleasant side effects. I discovered the issue while trying to figure out, why CSS animation on a server-rendered element was being reset during hydration.
The text was updated successfully, but these errors were encountered: