Skip to content
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: hydrate multiple <svelte:head> elements correctly #12475

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clever-toys-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: hydrate multiple `<svelte:head>` elements correctly
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function head(render_fn) {
block(() => render_fn(anchor), HEAD_EFFECT);
} finally {
if (was_hydrating) {
head_anchor = hydrate_node; // so that next head block starts from the correct node
set_hydrate_node(/** @type {TemplateNode} */ (previous_hydrate_node));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{@html '<meta name="head_nested_html" content="head_nested_html">'}
<meta name="head_nested" content="head_nested">
<meta name="head_nested" content="head_nested" />
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<script>
let text = $state('foo');
</script>

<svelte:head>
{@html '<meta name="nested_html" content="nested_html">'}
<meta name="nested" content="nested">
<meta name="nested" content="nested" />
<meta name="foo" content={text} />
</svelte:head>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
</script>

<svelte:head>
{@html '<meta name="main_html" content="main_html">'}
<meta name="main" content="main">
<HeadNested />
<!-- the if block forces a comment node; tests that the nested head starts at the correct node -->
{#if true}
{@html '<meta name="main_html" content="main_html">'}
<meta name="main" content="main" />
<HeadNested />
{/if}
</svelte:head>

<Nested/>
<Nested />
Loading