svelte icon indicating copy to clipboard operation
svelte copied to clipboard

[fix] Fix hydration duplicate `svelte:head` tag issue with `@html` expressions and nested components

Open maxiruani opened this issue 3 years ago • 0 comments

Fixes @html (#7444, #6463) expressions and nested components (#4533) duplication in a svelte:head tag on hydration.

  • Problem Adding a @html expression 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 any data-svelte attribute and could not be found by the claim logic and end up recreated.

  • Solution Deprecate data-svelte attribute 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 test and lint the project with npm run lint

maxiruani avatar Jul 31 '22 15:07 maxiruani

Any updates? This is presently blocking my team.

endigma avatar Aug 30 '22 16:08 endigma

@maxiruani perhaps re-request review? this seems to be dead in the water for some reason

endigma avatar Sep 11 '22 13:09 endigma