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

Duplicated tags from component inside svelte:head after hydration #6858

Closed
tdislay opened this issue Sep 16, 2022 · 2 comments
Closed

Duplicated tags from component inside svelte:head after hydration #6858

tdislay opened this issue Sep 16, 2022 · 2 comments

Comments

@tdislay
Copy link

tdislay commented Sep 16, 2022

Describe the bug

When you create a new svelte component, with some tags (title, meta, etc.) then use this component in svelte:head (in a layout.svelte), the tags inside the component get duplicated in the head section after hydration.

What I've tested:

  • Disable csr / ssr : it works fine, my tags didn't get duplicated
  • Extracting the tags from the component, and inserting them directly into layout.svelte : it works fine
  • Testing from firefox / chromium

I've found a weird workaround:
Surround with the svelte:head tag your tags inside the components, then you can put your component either inside or outside the svelte:head tag in the layout.svelte

Reproduction

routes>layout.ts

<script>
  import Title from '$lib/Title.svelte';
</script>
<svelte:head>
    <Title></Title>
</svelte:head>
<slot />

lib>Title.svelte

<title>Welcome</title>

-> Add a route>+page.svelte file to create a working route
-> npm run dev -- --open (same result with npm run build && npm run preview)
-> Open the webpage, check source => The tags got duplicated

Logs

No response

System Info

System:
    OS: Linux 5.15 Manjaro Linux
    CPU: (12) x64 AMD Ryzen 5 1600 Six-Core Processor
    Memory: 15.91 GB / 23.42 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Chromium: 105.0.5195.102
    Firefox: 104.0.2
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.0-next.75 => 1.0.0-next.75 
    @sveltejs/kit: next => 1.0.0-next.484 
    svelte: ^3.44.0 => 3.50.1 
    vite: ^3.1.0 => 3.1.1

Severity

annoyance

Additional Information

No response

@benmccann
Copy link
Member

I'm guessing this is a duplicate of sveltejs/svelte#4533, sveltejs/svelte#6463, sveltejs/svelte#7444. The issue will be fixed in the next release of Svelte

@tdislay
Copy link
Author

tdislay commented Sep 17, 2022

Yes, it is, my bad. Thank you :)

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

2 participants