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

<!doctype html> shows errors #204

Closed
matthewmueller opened this issue Jun 18, 2020 · 3 comments
Closed

<!doctype html> shows errors #204

matthewmueller opened this issue Jun 18, 2020 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@matthewmueller
Copy link

matthewmueller commented Jun 18, 2020

Describe the bug

<!doctype html> shows errors. Looks related to #143.

To Reproduce

CleanShot 2020-06-18 at 09 50 11@2x

CleanShot 2020-06-18 at 09 54 13@2x

<!doctype html />
<html lang="en">
  <slot name="head" />
  <body>
    <slot name="view" />
    <slot name="script" />
  </body>
</html>

Removing the doctype fixes the problem. I also tried <!doctype html>, but auto-formatting inserts <!doctype html /> anyway.

Expected behavior

No errors. Seems like it's fixed in svelte: sveltejs/svelte#336

I wasn't able to reproduce it in the Svelte REPL (I got a different error), but I think this should work with SSR.

System (please complete the following information):

  • OS: OSX
  • IDE: VSCode
  • Plugin/Package: Svelte Beta v99.0.46
@matthewmueller matthewmueller added the bug Something isn't working label Jun 18, 2020
@dummdidumm
Copy link
Member

dummdidumm commented Jun 18, 2020

It's a svelte2tsx problem. Output of given input is:

<></>;function render() {
<><!doctype html />
<html lang="en">
  <slot name="head" />
  <body>
    <slot name="view" />
    <slot name="script" />
  </body>
</html></>
return { props: {}, slots: {head: {}, view: {}, script: {}} }}

export default class {
    $$prop_def = __sveltets_partial(render().props)
    $$slot_def = render().slots
}

<!doctype html /> is not a valid jsx tag, so it throws these syntax errors. I think the best solution would be to check inside svelte2tsx if such a string exists at the start of the document and just remove it during conversion to jsx, using a regex that checks "is there a tag that begins with <!doctype in the beginning".

@dummdidumm dummdidumm added the good first issue Good for newcomers label Jun 18, 2020
@skippednote
Copy link
Contributor

@dummdidumm Based on your suggestion, I've created a pull request #213.

@dummdidumm
Copy link
Member

Thanks @skippednote ! Fix will be available in about 20 hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants