Skip to content

Commit 0070062

Browse files
authored
fix: html tag hydration: regard empty claimed_nodes array as content mismatch (#9184)
fixes #6832
1 parent d8e3827 commit 0070062

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

.changeset/spicy-shrimps-divide.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: more robust hydration of html tag

packages/svelte/src/runtime/internal/dom.js

+3
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,9 @@ export function claim_html_tag(nodes, is_svg) {
807807
detach(html_tag_nodes[0]);
808808
detach(html_tag_nodes[html_tag_nodes.length - 1]);
809809
const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);
810+
if (claimed_nodes.length === 0) {
811+
return new HtmlTagHydration(is_svg);
812+
}
810813
for (const n of claimed_nodes) {
811814
n.claim_order = nodes.claim_info.total_claimed;
812815
nodes.claim_info.total_claimed += 1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
 1
2+
<!-- HTML_TAG_START -->2<!-- HTML_TAG_END -->
3+
3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
const a = 1, b=2, c=3;
3+
</script>
4+
5+
{a} {@html b} {c}

0 commit comments

Comments
 (0)