fix: html tag hydration: regard empty claimed_nodes array as content mismatch (#9184)

fixes #6832
pull/9379/head
Kelvin Soh 2 years ago committed by GitHub
parent d8e382712c
commit 00700621bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: more robust hydration of html tag

@ -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;

@ -0,0 +1,3 @@
 1
<!-- HTML_TAG_START -->2<!-- HTML_TAG_END -->
3

@ -0,0 +1,5 @@
<script>
const a = 1, b=2, c=3;
</script>
{a} {@html b} {c}
Loading…
Cancel
Save