diff --git a/src/compiler/compile/render_ssr/handlers/Head.ts b/src/compiler/compile/render_ssr/handlers/Head.ts index c7b315ae64..f4bb3fa118 100644 --- a/src/compiler/compile/render_ssr/handlers/Head.ts +++ b/src/compiler/compile/render_ssr/handlers/Head.ts @@ -12,5 +12,5 @@ export default function(node: Head, renderer: Renderer, options: RenderOptions) renderer.render(node.children, head_options); const result = renderer.pop(); - renderer.add_expression(x`$$result.head += '' + ${result} + '', ""`); + renderer.add_expression(x`$$result.head += '' + ${result} + '', ""`); } diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 8aacd94856..37d920c6f5 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -645,12 +645,15 @@ export function head_selector(nodeId: string, head: HTMLElement) { let started = 0; for (const node of head.childNodes) { - if (node.nodeType === 8 /* comment node */ && node.textContent.trim() === `HEAD_END data-svelte="${nodeId}"`) { - started -= 1; - result.push(node); - } else if (node.nodeType === 8 /* comment node */ && node.textContent.trim() === `HEAD_START data-svelte="${nodeId}"`) { - started += 1; - result.push(node); + if (node.nodeType === 8 /* comment node */) { + const comment = node.textContent.trim(); + if (comment === `HEAD_${nodeId}_END`) { + started -= 1; + result.push(node); + } else if (comment === `HEAD_${nodeId}_START`) { + started += 1; + result.push(node); + } } else if (started > 0) { result.push(node); } diff --git a/test/hydration/samples/head-html-and-component/_after_head.html b/test/hydration/samples/head-html-and-component/_after_head.html index 0d379ce562..d7f94eda1b 100644 --- a/test/hydration/samples/head-html-and-component/_after_head.html +++ b/test/hydration/samples/head-html-and-component/_after_head.html @@ -1,12 +1,12 @@ - + - + - + - + diff --git a/test/hydration/samples/head-html-and-component/_before_head.html b/test/hydration/samples/head-html-and-component/_before_head.html index 130c18254c..da265f414d 100644 --- a/test/hydration/samples/head-html-and-component/_before_head.html +++ b/test/hydration/samples/head-html-and-component/_before_head.html @@ -1,11 +1,11 @@ - + - + - + - + diff --git a/test/hydration/samples/head-meta-hydrate-duplicate/_after_head.html b/test/hydration/samples/head-meta-hydrate-duplicate/_after_head.html index 5e90150217..bdd08c32f5 100644 --- a/test/hydration/samples/head-meta-hydrate-duplicate/_after_head.html +++ b/test/hydration/samples/head-meta-hydrate-duplicate/_after_head.html @@ -1,6 +1,6 @@