-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Svelte 5: component hydration not repairing/removing target child elements #10375
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
We will likely adjust this to provide a |
Thanks for the update @dummdidumm. So as it stands there is no equivalent of v4's Appreciate all the hard work. |
Right now you can just use |
Our app is a
If I interpret this correctly, it hydrates automatically only if the correct comments exists? This seems like a big step backwards unless there is a planned API that can hydrate without comments. Adding a requirement to have Svelte specific comments in the markup to enable hydration, were the requirement did not exist previously, seems like this functionality was designed with only Again, thanks for all the hard work. |
I may have skimmed over this, the Edit:
Ok, that answers my question. I'll close this as it's working as intended and the missing feature I'm after is incoming. Thanks @dummdidumm |
No I think you misunderstood - the TBH I'm not sure if we can really do something here other than note it in the breaking changes. Keeping the HTML in sync manually is very brittle and Svelte already used hydration comments in a few places for Svelte 4 (for example when using By the way - while there is an error logged (it's not thrown, just logged and doesn't stop anything), the app will still be functional. What Svelte does is remove the inner HTML of the target anchor and recreate the DOM nodes from scratch. So the result should be mostly equivalent to the user (edge cases: flickering; you want to preserve certain state which may be reset). |
So this is a feature that is being removed in
An example of where we use this is a search autocompletion, with the All the above being said, if the decision has been made to require |
Describe the bug
As per the v4 Client API docs, a component can be created with the
hydrate: true
option to repair and remove existing child elements of the target.The v5 breaking changes docs state that the compiler option
hydratable
has bees removed and all components are now hydrated and components are now created withcreateRoot
ormount
. Neither of these functions accepthydrate: true
as an option.When using
createRoot
ormount
in v5, child elements of target are left unchanged. The expected behaviour is that of v4 (withhydrate: true
) and DOM elements are repaired/removed.Possibly related
#9827, #10332
Reproduction
minimum repo
Logs
No response
System Info
The text was updated successfully, but these errors were encountered: