Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix claim_text #6275

Merged
merged 1 commit into from
May 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>