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> empty <title> error handling #2980

Closed
zurp opened this issue Jun 2, 2019 · 4 comments · Fixed by #2988
Closed

<svelte:head> empty <title> error handling #2980

zurp opened this issue Jun 2, 2019 · 4 comments · Fixed by #2988
Labels

Comments

@zurp
Copy link

zurp commented Jun 2, 2019

When using an empty <title> tag in <svelte:head> a client error will be thrown.

To reproduce add this in routes/index.svelte:

<svelte:head>
  <title></title>
</svelte:head>

The error is: Cannot read property 'data' of undefined.
When trying to build the full stack trace is visible (hidden in dev mode):

TypeError: Cannot read property 'data' of undefined
    at TitleWrapper.render (project/node_modules/svelte/compiler.js:17301:60)
    at FragmentWrapper.render (project/node_modules/svelte/compiler.js:17540:28)
    at HeadWrapper.render (project/node_modules/svelte/compiler.js:16270:24)
    at FragmentWrapper.render (project/node_modules/svelte/compiler.js:17540:28)
    at new Renderer (project/node_modules/svelte/compiler.js:17571:24)
    at dom (project/node_modules/svelte/compiler.js:17762:23)
    at compile (project/node_modules/svelte/compiler.js:23767:16)
    at preprocessPromise.then.code (project/node_modules/rollup-plugin-svelte/index.js:236:22)

This is confusing when an empty title tag is used (when starting a new project and leaving it empty as a placeholder), as the error is not helpful. Adding content inside the tag will work just fine.

@brunetton
Copy link

(useless comment): same here, I was on the point to open the same issue :)

@jcollum
Copy link

jcollum commented Jun 6, 2019

OK but why not just leave the title off or bind it to something?

@zurp
Copy link
Author

zurp commented Jun 6, 2019

OK but why not just leave the title off or bind it to something?

I think it should not crash at all to be honest, an empty title tag is valid, no framework should reinterpret html.

But if it does crash because of this, it should at least throw an error that explains the issue is the empty tag. Otherwise we have people all over the world debugging this over and over again, and putting the head section with an empty title as placeholder for later modification is not uncommon.

@Conduitry Conduitry transferred this issue from sveltejs/sapper Jun 9, 2019
@Conduitry Conduitry added the bug label Jun 9, 2019
@Conduitry
Copy link
Member

This is actually a Svelte bug - I've transferred the issue.

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

Successfully merging a pull request may close this issue.

4 participants