-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: improve hydration of svelte head blocks #11099
Conversation
🦋 Changeset detectedLatest commit: 1e19135 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably an edge case, but what if a component is rendered on the server but not on the client, and it contains svelte:head
? Then the wrong head would be used for hydration. I think we need to add a number to each head anchor to know which ones to ignore. It should be enough to check for anchor of number n and remove all previously encountered anchor pairs (and everything inbetween) that weren't hydrated.
I'll explore this approach.
Thinking about it more - I don't currently see how we can reliably identify a marker between client and server.
Almost feels like we need a general-purpose "create a unique id that is stable across client and server" mechanism for this (something from which users probably also benefit). |
How does Svelte 4 deal with this? I have a way of dealing with it, but easiest to speak about it in a call first. |
I haven't tested, but Svelte 4 basically clears each mismatch separately and recreates the nodes from scratch. |
@dummdidumm What if there are no mismatches but there's still additional content in the head that is wrong? i.e. you have an each block that renders to the head in each row, but the server renders 5 items and the client renders 4? |
Fixes #11092