svelte
svelte copied to clipboard
[fix] Fix hydration duplicate `svelte:head` tag issue with `@html` expressions and nested components
Fixes @html (#7444, #6463) expressions and nested components (#4533) duplication in a svelte:head tag on hydration.
-
Problem Adding a
@htmlexpression or<Component />within a<svelte:head>ends up duplicated after hydration. -
Why? Attribute
data-svelte="head_id"was added only to nearest child elements and hydration claim was based exclusively on getting elements with that attribute.@htmlexpressions and components were left without anydata-svelteattribute and could not be found by the claim logic and end up recreated. -
Solution Deprecate
data-svelteattribute for nearest child elements and wrap the whole head content with 2 comments:<!-- HEAD_START data-svelte="head_id" --><!-- HEAD_END data-svelte="head_id" -->
Inspired by @hbirler comment HTML_TAG_X claim proposal.
Before submitting the PR, please make sure you do the following
- [X] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [X] Prefix your PR title with
[feat],[fix],[chore], or[docs]. - [X] This message body should clearly illustrate what problems it solves.
- [X] Ideally, include a test that fails without this PR but passes with it.
Tests
- [X] Run the tests with
npm testand lint the project withnpm run lint
Any updates? This is presently blocking my team.
@maxiruani perhaps re-request review? this seems to be dead in the water for some reason