Skip to content

Commit

Permalink
fix: head duplication when binding is present (#9124)
Browse files Browse the repository at this point in the history
fixes #7879
fixes #4982
  • Loading branch information
gtm-nayan authored Aug 28, 2023
1 parent 2691e19 commit d5839ef
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-terms-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: head duplication when binding is present
4 changes: 4 additions & 0 deletions packages/svelte/src/compiler/compile/render_ssr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ export default function ssr(component, options) {
? b`
let $$settled;
let $$rendered;
let #previous_head = $$result.head;
do {
$$settled = true;
// $$result.head is mutated by the literal expression
// need to reset it if we're looping back to prevent duplication
$$result.head = #previous_head;
${reactive_declarations}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
export let bar = null
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<link rel="canonical" href="/test">
<meta name="description" content="test">
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script>
import Foo from './Foo.svelte';
let bar;
</script>

<svelte:head>
<link rel="canonical" href="/test" />
<meta name="description" content="test" />
</svelte:head>

<Foo bind:bar />

0 comments on commit d5839ef

Please sign in to comment.