Skip to content

Commit

Permalink
fix: html tag hydration: regard empty claimed_nodes array as content …
Browse files Browse the repository at this point in the history
…mismatch (#9184)

fixes #6832
  • Loading branch information
kelvinsjk authored Nov 10, 2023
1 parent d8e3827 commit 0070062
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-shrimps-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: more robust hydration of html tag
3 changes: 3 additions & 0 deletions packages/svelte/src/runtime/internal/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,9 @@ export function claim_html_tag(nodes, is_svg) {
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);
if (claimed_nodes.length === 0) {
return new HtmlTagHydration(is_svg);
}
for (const n of claimed_nodes) {
n.claim_order = nodes.claim_info.total_claimed;
nodes.claim_info.total_claimed += 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 2 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
 1
<!-- HTML_TAG_START -->2<!-- HTML_TAG_END -->
3
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
const a = 1, b=2, c=3;
</script>

{a} {@html b} {c}

0 comments on commit 0070062

Please sign in to comment.