Skip to content

{@html} hydration in head duplicates elements #6463

@benmccann

Description

@benmccann

Describe the bug

@html markup in head is being rendered twice. I also noticed that HTML_TAG_END is occurring before HTML_TAG_START, which seems backwards. I believe that @tanhauhau tried to implement / fix this in #4444, but it looks like there may be a kink to work out still

Reproduction

Add this code to a SvelteKit app:

<script> const item_title = 'Hello world!'; const schema = { "@context": "http://schema.org", "@type": "Article", "@name": item_title }; </script> <svelte:head> {@html '<script type="application/ld+json">' + JSON.stringify(schema) + '</script>'} </svelte:head> 

It was originally reported in the SvelteKit repo sveltejs/kit#1035 as there being an issue only on build with adapter-static, but I'm seeing it even with npm run dev. I think that the originally reported issue may have been a bit different perhaps relying on a slightly older version of Svelte before #4444 was merged

Logs

Inspect element in Chrome and see this: <head> <script type="application/ld+json">{"@context":"http://schema.org","@type":"Article","@name":"Hello world!"}</script> <!-- HTML_TAG_END --><script type="application/ld+json">{"@context":"http://schema.org","@type":"Article","@name":"Hello world!"}</script><!-- HTML_TAG_START --> </head>
 ### System Info ```shell npmPackages: @sveltejs/kit: next => 1.0.0-next.118 svelte: ^3.34.0 => 3.38.3 

Severity

annoyance

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions