Open
Description
Describe the problem
When a parent component has a <svelte:head>
tag and a nested component inside it with a also a <svelte:head>
, the content of the head tag of the nested component is stripped out in SSR.
Example:
Parent component
<script>
import ChildNested from './ChildNested.svelte'
</script>
<svelte:head> _PREFIX_ <ChildNested /> _SUFFIX_</svelte:head>
Child component
<svelte:head>_NESTED_HEAD_</svelte:head>
_NESTED_BODY_
Simple reproduction REPL, you can see the generated code for SSR at JS output tab.
Pseudo equivalent generated code to understand the problem within the browser console:
const $$result = { head: '' };
function $$render(result) {
result.head += '_NESTED_HEAD_';
return '_NESTED_BODY_';
}
$$result.head += `_PREFIX_ ${$$render($$result)} _SUFFIX_`;
console.log($$result.head); // Logs "_PREFIX_ _NESTED_BODY_ _SUFFIX_"
Describe the proposed solution
At $$render
if parent is a svelte:head
return head content as body.
Alternatives considered
Maybe changing what create_ssr_component
returns (return both head and body) or separate head and body rendering in different statements.
Importance
nice to have