Skip to content

Commit

Permalink
fix claim_text (#6275)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau authored May 1, 2021
1 parent b3a642c commit 94bfeae
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime/internal/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function claim_text(nodes, data) {
const node = nodes[i];
if (node.nodeType === 3) {
node.data = '' + data;
return nodes.shift();
return nodes.splice(i, 1)[0];
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/hydration/samples/claim-text/Component.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<svelte:head>
<title>Title</title>
</svelte:head>

<main>There should be one</main>
2 changes: 2 additions & 0 deletions test/hydration/samples/claim-text/Layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p>This <code>p</code> and the <code>slot</code> below are direct children of the root.</p>
<slot />
3 changes: 3 additions & 0 deletions test/hydration/samples/claim-text/_after.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>This <code>p</code> and the <code>slot</code> below are direct children of the root.</p>

<main>There should be one</main>
5 changes: 5 additions & 0 deletions test/hydration/samples/claim-text/_before.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p>This <code>p</code> and the <code>slot</code> below are direct children of the root.</p>

<main>There should be one</main>

<!-- need extra space after <main> -->
8 changes: 8 additions & 0 deletions test/hydration/samples/claim-text/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script>
import Layout from './Layout.svelte';
import Component from './Component.svelte';
</script>

<Layout>
<Component />
</Layout>

0 comments on commit 94bfeae

Please sign in to comment.