Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pretty-trees-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: use non-destructive hydration for all `@html` tags
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class RawMustacheTagWrapper extends Tag {
render(block, parent_node, _parent_nodes) {
const in_head = is_head(parent_node);
const can_use_innerhtml = !in_head && parent_node && !this.prev && !this.next;
if (can_use_innerhtml) {
if (can_use_innerhtml && !this.renderer.options.hydratable) {
/** @param {import('estree').Node} content */
const insert = (content) => b`${parent_node}.innerHTML = ${content};`[0];
const { init } = this.rename_this_method(block, (content) => insert(content));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
export default {
html: `
<svg>
<foreignObject>
<circle cx="25" cy="30" r="24" fill="#FFD166"></circle>
</foreignObject>
<foreignObject><!-- HTML_TAG_START --><circle cx="25" cy="30" r="24" fill="#FFD166"></circle><!-- HTML_TAG_END --></foreignObject>
</svg>
`,
test({ assert, target, component }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
export let width = 100
export let height = 60
$: circle = `<circle cx="${width/4}" cy="${height/2}" r="24" fill="#FFD166"/>`
export let width = 100;
export let height = 60;
$: circle = `<circle cx="${width / 4}" cy="${height / 2}" r="24" fill="#FFD166"></circle>`;
</script>

<svg>
Expand Down