Skip to content

Commit 895b4c6

Browse files
authored
[fix] hydrate correct elements when using @html (#6946)
1 parent 26f767e commit 895b4c6

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

src/runtime/internal/dom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ export function claim_html_tag(nodes) {
501501
}
502502

503503
init_claim_info(nodes);
504-
const html_tag_nodes = nodes.splice(start_index, end_index + 1);
504+
const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);
505505
detach(html_tag_nodes[0]);
506506
detach(html_tag_nodes[html_tag_nodes.length - 1]);
507507
const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
<div>before</div>
3+
<br>
4+
5+
<!-- HTML_TAG_START -->a <!-- HTML_TAG_END --><!-- HTML_TAG_START -->b <!-- HTML_TAG_END --><!-- HTML_TAG_START -->c <!-- HTML_TAG_END -->
6+
<div>after</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
<div>before</div>
3+
<br>
4+
5+
<!-- HTML_TAG_START -->a <!-- HTML_TAG_END --><!-- HTML_TAG_START -->b <!-- HTML_TAG_END --><!-- HTML_TAG_START -->c <!-- HTML_TAG_END -->
6+
<div>after</div>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
let content = ["a ", "b ", "c "];
3+
</script>
4+
5+
<div>before</div>
6+
<br>
7+
8+
{#each content as c}
9+
{@html c}
10+
{/each}
11+
<div>after</div>

0 commit comments

Comments
 (0)