From 60afc45b233cd6783f3a1e4d36b0e0bf864d21ee Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Thu, 29 Jun 2023 15:46:43 +0200 Subject: [PATCH] fix: use non-destructive hydration for all `@html` tags fixes https://github.com/sveltejs/kit/issues/10245 --- .changeset/pretty-trees-prove.md | 5 +++++ .../compiler/compile/render_dom/wrappers/RawMustacheTag.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/pretty-trees-prove.md diff --git a/.changeset/pretty-trees-prove.md b/.changeset/pretty-trees-prove.md new file mode 100644 index 000000000000..9c5cdfa7134e --- /dev/null +++ b/.changeset/pretty-trees-prove.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: use non-destructive hydration for all `@html` tags diff --git a/packages/svelte/src/compiler/compile/render_dom/wrappers/RawMustacheTag.js b/packages/svelte/src/compiler/compile/render_dom/wrappers/RawMustacheTag.js index 11a838ab8e95..cc382a9b0bb1 100644 --- a/packages/svelte/src/compiler/compile/render_dom/wrappers/RawMustacheTag.js +++ b/packages/svelte/src/compiler/compile/render_dom/wrappers/RawMustacheTag.js @@ -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));