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

Stray } in element is interpreted as an attribute and causes a runtime error #4648

Closed
dimfeld opened this issue Apr 7, 2020 · 1 comment · Fixed by #4650
Closed

Stray } in element is interpreted as an attribute and causes a runtime error #4648

dimfeld opened this issue Apr 7, 2020 · 1 comment · Fixed by #4650
Labels

Comments

@dimfeld
Copy link
Contributor

dimfeld commented Apr 7, 2020

Describe the bug
When Svelte sees an element with an orphaned } character it interprets the bracket as an attribute. e.g.

<h1 }>text</h1>
causes this to be generated in the create function:
attr(h1, "}", "");
and causes the runtime error
Failed to execute 'setAttribute' on 'Element': '}' is not a valid attribute name.

REPL: https://svelte.dev/repl/14ee9617902447809daec74565b61a8e?version=3.20.1

Expected behavior
IMO the compiler should throw an error instead of generating code for this.

Severity
Not too important. Was pretty obvious what happened when I looked back at my source file and saw the } character I missed deleting.

@dimfeld dimfeld changed the title Stray } in element is interpreted as an attribute and causes a runti,e error Stray } in element is interpreted as an attribute and causes a runtime error Apr 7, 2020
dimfeld added a commit to dimfeld/svelte that referenced this issue Apr 8, 2020
@Conduitry Conduitry added the bug label Apr 15, 2020
@Conduitry
Copy link
Member

This is now a compile time error rather than a runtime one - https://svelte.dev/repl/14ee9617902447809daec74565b61a8e?version=3.21.0

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.

2 participants