-
-
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
Empty comment in HTML breaks hydration #14323
Comments
The hash is only added during dev to give you the runtime error in case of mismatch and will not be there in production. But also, considering that what you are trying to achieve is purely client side why do you need this? |
Hmm... So, there are no hashes in prod... Could it be a good idea to make comments defining While most of what I need is client-side, it still operates on DOM coming from the server (CSR-only is unacceptable in my use case). Since Svelte doesn't have partial (component level) hydration yet, using the The ultimate goal of this is to preserve state (including DOM references and any modifications done outside of Svelte) between route navigations. E.g. imagine a tab-view where each tab is its own route with SSR, but when navigating between them on a client you keep all the state for each tab. Unfortunately, |
I've made a full-stack tab-view demo. Note the |
I wonder if the correct solution is that we have a better API for these cases, see #14337. |
#14337 would solve this issue. Unfortunately, this issue is just a part of a problem for my use-case. There are some other problems with my current implementation. For example, any transitions inside |
I don't think #14337 solves this use case because of the intention to hydrate the ssr-d output (to avoid svelte-controlled unmount). #14337 would help with purely server components with no interactivity or just static email markup. This issue is purely on the hydration mismatch warning (supposedly in dev only) when used in rendering components via the server-side |
After speaking to @Rich-Harris about this, we feel the correct fix for this is to make it so the |
Describe the bug
The Problem
I'm trying to implement a manual hydration for some parts of my application. Which means I need to render components to a string and pass them to
@html
to avoid Svelte hydrating this parts of my application automatically. E.g.The problem is that
render(someComponent).body
contains empty comments (<!---->
) for its future hydration. And you get a mismatch because these comments are misinterpreted as the end of@html
block.Possible Solution
Make sure that
@html
block are closed with a "hash comment" and ignore every other comment. This change should be as simple as replacing(next).data !== ''
with(next).data !== hash
here. If this is an acceptable solution, I can make a PR.Use Case
My use case might seem weird to you. I've posted more details on discord. We could discuss it there if needed.
Reproduction
Minimal reproduction:
Observe:
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: