Skip to content

Child inside the svelte:head is not removed from DOM when the parent is unmounted #8202

Closed as not planned
@tontonsb

Description

@tontonsb

Describe the bug

If the following component is included and subsequently removed, the document head still contains whatever Child is.

<!-- MyComponent.svelte -->
<script>
    import Child from './Child.svelte'
</script>

<svelte:head>
    <Child />
</svelte:head>

I see a lot of similar bugs in this and Kit's issue history, but this still seems present in the latest release.

Reproduction

https://svelte.dev/repl/54395e0587fc49cebf931d11f57f22dc?version=3.55.1

Click the button in the REPL to repeatedly add and remove a Head element, which has the following HTML:

<svelte:head>
	<Title {title} />  <!-- this contains <title>{title}</title> -->
	<meta name="test">
</svelte:head>

You'll see that when Head is added, the title and meta are both added to DOM (inspect it or just look at the counters). When Head is removed the title still remains (but it shouldn't) while meta is correctly cleaned up.

Logs

No response

System Info

Svelte 3.55.1

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions