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

Conditional elements inside <svelte:head> throw console errors on hydration. #1406

Closed
morleytatro opened this issue May 2, 2018 · 6 comments
Labels

Comments

@morleytatro
Copy link

At least two types of tags are throwing errors when included conditionally: link and meta. This only seems to be an issue when using Sapper. With Svelte alone and no server-side rendering, the problem doesn't occur. See this repo and specifically lines 2-4 of the Layout.html file. The conditional is the only thing added to the Sapper template. The error thrown is:

TypeError: Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'.

@Rich-Harris Rich-Harris added the bug label May 3, 2018
@ludwigschubert
Copy link

ludwigschubert commented May 30, 2018

FYI @morleytatro we ran into the same issue with an {#each} block around meta tags. Our workaround is to use a nested child component that has the <svelte:head> directive.

@morleytatro
Copy link
Author

Here's another repro:
https://github.com/morleytatro/svelte-head-test/tree/head-conditionals

Simply install the modules and fire it up with yarn start or npm run start.

Seems like this might be connected to either or both of these:
sveltejs/sapper#475
#1774

@morleytatro morleytatro changed the title Conditional elements (link and meta) inside <svelte:head> throw console errors. Conditional elements inside <svelte:head> throw console errors on hydration. Oct 30, 2018
@antony
Copy link
Member

antony commented Oct 30, 2018

Yes, I raised #475 for this exact same reason, as I'm trying to build a favicon plugin which dynamically generates and includes required assets, and as it stands, it can't work.

An important thing to note here is that the solution by @ludwigschubert doesn't work, under sapper, at least. Any each I try to write, no matter how far down I try to bury it in child components, breaks :)

@Panya
Copy link
Contributor

Panya commented Jun 20, 2019

It was fixed in 3.4.4 and above.

@morleytatro
Copy link
Author

@Panya Confirmed. I'll close it.

@RobbieTheWagner
Copy link

I'm still not able to use {#each} in <svelte:head> in Sapper.

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

No branches or pull requests

6 participants