Skip to content

Use innerHTML in more places #3343

@Rich-Harris

Description

@Rich-Harris

Moving this from #3341. 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);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions