From 8886e416470fb01b3e7aa15646c374a006195b87 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Sat, 20 Nov 2021 01:08:24 +0900 Subject: [PATCH] fix claim_html_tag bug --- 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 eb3389e3f8..0edd0115c7 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