Skip to content
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

svelte:head does not remove title tag #7656

Open
mallsoft opened this issue Jul 4, 2022 · 2 comments
Open

svelte:head does not remove title tag #7656

mallsoft opened this issue Jul 4, 2022 · 2 comments

Comments

@mallsoft
Copy link

mallsoft commented Jul 4, 2022

Describe the bug

A title tag added using <svelte:head>, cannot be removed? like you can with any other tag i have tested (meta, script).

Reproduction

<svelte:head>
	{#if toggleBool}
	<!-- stays put even if toggleBool is false  -->
		<title>Title injected!!!</title>

	<!-- gets removed as expected  -->
		<meta name="description" content="I am ALIVE" />

	<!-- gets removed as expected  -->
		<script>
			console.log('I am alive!');
		</script>
	{/if}
</svelte:head>

Relevant repl: https://svelte.dev/repl/2ecf81b43d0d4b2eaa02d80adf803929?version=3.48.0

Logs

No response

System Info

Windows 10, Firefox & Edge, svelte repl 3.48.0

Severity

annoyance

@pedeEli
Copy link

pedeEli commented Jul 6, 2022

I think thats on purpose, because when you would remove the title, without setting a new one the page would have no title at all. So the only way to change the title is to set a new one.
You could of cause keep track of the previeous titles and set it to the last one. This could be a possible solution

@UnlimitedBytes
Copy link

This actually blocks fallback titles, maybe we can (at least) remove the title when one is present in a parent, like:

<!-- src/routes/+layout.svelte -->
<svelte:head>
  <title>Fallback</title>
</svelte:head>
<!-- src/routes/+page.svelte -->
<svelte:head>
  <title>Home</title>
</svelte:head>

<a href="/404">Go to 404 page</a>

Give the above example a direct call to "/404" will result in the title "Fallback" while a call using CSR will result in the old title "Home" still being displayed instead of the fallback one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants