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

Commas in generated HTML #3341

Closed
Rich-Harris opened this issue Aug 3, 2019 · 0 comments · Fixed by #3342
Closed

Commas in generated HTML #3341

Rich-Harris opened this issue Aug 3, 2019 · 0 comments · Fixed by #3342
Labels

Comments

@Rich-Harris
Copy link
Member

Describe the bug

When portions of markup are turned into HTML, attributes with interpolated literals (insofar as that's not an oxymoron) contain unwanted commas

To Reproduce

<div>
  <span class="a/{42}"/>
</div>

This needs to be compiled in production mode, since elements are never converted to static HTML in dev mode.

https://svelte.dev/repl/bf37bbf244594248b444a50ad3b95c73?version=3.6.10

Expected behavior

The chunks of the attribute should be concatenated without commas

Severity

Low, since attributes with interpolated literals are somewhat rare.

Additional context

In a case like this...

<script>
  const answer = 42;
</script>

<div>
  <span class="a/{answer}"/>
</div>

...Svelte should recognise that answer cannot change, and so it's ok to use innerHTML:

-span = element("span");
-attr(span, "class", span_class_value = "a/" + answer);
+div.innerHTML = `<span class="a/${answer}"></span>`;
// ...
-append(div0, span);
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.

1 participant