0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-30 00:46:29 +01:00

[fix] hydrate correct elements when using @html (#6946)

This commit is contained in:
Yuichiro Yamashita 2022-01-09 23:12:57 +09:00 committed by GitHub
parent 26f767e873
commit 895b4c6721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 1 deletions

View File

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

View File

@ -0,0 +1,6 @@
<div>before</div>
<br>
<!-- HTML_TAG_START -->a <!-- HTML_TAG_END --><!-- HTML_TAG_START -->b <!-- HTML_TAG_END --><!-- HTML_TAG_START -->c <!-- HTML_TAG_END -->
<div>after</div>

View File

@ -0,0 +1,6 @@
<div>before</div>
<br>
<!-- HTML_TAG_START -->a <!-- HTML_TAG_END --><!-- HTML_TAG_START -->b <!-- HTML_TAG_END --><!-- HTML_TAG_START -->c <!-- HTML_TAG_END -->
<div>after</div>

View File

@ -0,0 +1,11 @@
<script>
let content = ["a ", "b ", "c "];
</script>
<div>before</div>
<br>
{#each content as c}
{@html c}
{/each}
<div>after</div>