-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Child inside the svelte:head
is not removed from DOM when the parent is unmounted
#8202
Comments
Btw here's a workaround for the repl case. Remove the <!-- Head.svelte -->
<script>
import Title from './Title.svelte'
import {onDestroy} from 'svelte'
export let title = ''
let enabled = true
onDestroy(() => enabled = false)
</script>
<svelte:head>
{#if enabled}
<Title {title} />
{/if}
<meta name="test">
</svelte:head> Trying the same cleanup inside |
Closing as duplicate of #7656 |
@dummdidumm it's not a duplicate, it was another issue. This issue was about child components inside head. They are never removed, reinserting the component duplicates the contents of the component (and makes additional copy of contents on every reinsert) and it doesn't matter if you put a title tag or anything else in the However, the issue has been fixed in Svelte 5: https://svelte.dev/playground/54395e0587fc49cebf931d11f57f22dc?version=5.1.3 So it is still probably fine to close this. The #7656 issue on the other hand is some quirk related to |
Thanks for the explanation, and sorry for the confusion. Keeping this closed because as you say it's fixed in Svelte 5 |
Describe the bug
If the following component is included and subsequently removed, the document head still contains whatever
Child
is.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:You'll see that when
Head
is added, thetitle
andmeta
are both added to DOM (inspect it or just look at the counters). WhenHead
is removed thetitle
still remains (but it shouldn't) whilemeta
is correctly cleaned up.Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: