Describe the bug
<!doctype html>
shows errors. Looks related to https://github.com/sveltejs/language-tools/issues/143.
To Reproduce
<!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: https://github.com/sveltejs/svelte/issues/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):
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
@dummdidumm Based on your suggestion, I've created a pull request #213.
Thanks @skippednote ! Fix will be available in about 20 hours.
Most helpful comment
@dummdidumm Based on your suggestion, I've created a pull request #213.