From 895b4c67210b37b671089a334998c942371d015e Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Sun, 9 Jan 2022 23:12:57 +0900 Subject: [PATCH] [fix] hydrate correct elements when using `@html` (#6946) --- src/runtime/internal/dom.ts | 2 +- .../samples/raw-with-empty-line-at-top/_after.html | 6 ++++++ .../samples/raw-with-empty-line-at-top/_before.html | 6 ++++++ .../samples/raw-with-empty-line-at-top/main.svelte | 11 +++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/hydration/samples/raw-with-empty-line-at-top/_after.html create mode 100644 test/hydration/samples/raw-with-empty-line-at-top/_before.html create mode 100644 test/hydration/samples/raw-with-empty-line-at-top/main.svelte diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index a8b542053b..972b1ff537 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -501,7 +501,7 @@ export function claim_html_tag(nodes) { } init_claim_info(nodes); - const html_tag_nodes = nodes.splice(start_index, end_index + 1); + const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1); detach(html_tag_nodes[0]); detach(html_tag_nodes[html_tag_nodes.length - 1]); const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1); diff --git a/test/hydration/samples/raw-with-empty-line-at-top/_after.html b/test/hydration/samples/raw-with-empty-line-at-top/_after.html new file mode 100644 index 0000000000..28ee6452d3 --- /dev/null +++ b/test/hydration/samples/raw-with-empty-line-at-top/_after.html @@ -0,0 +1,6 @@ + +
before
+
+ +a b c +
after
diff --git a/test/hydration/samples/raw-with-empty-line-at-top/_before.html b/test/hydration/samples/raw-with-empty-line-at-top/_before.html new file mode 100644 index 0000000000..28ee6452d3 --- /dev/null +++ b/test/hydration/samples/raw-with-empty-line-at-top/_before.html @@ -0,0 +1,6 @@ + +
before
+
+ +a b c +
after
diff --git a/test/hydration/samples/raw-with-empty-line-at-top/main.svelte b/test/hydration/samples/raw-with-empty-line-at-top/main.svelte new file mode 100644 index 0000000000..2d08a3f418 --- /dev/null +++ b/test/hydration/samples/raw-with-empty-line-at-top/main.svelte @@ -0,0 +1,11 @@ + + +
before
+
+ +{#each content as c} + {@html c} +{/each} +
after