diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 03f076df5e..b0cc2c5841 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -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]; } } diff --git a/test/hydration/samples/claim-text/Component.svelte b/test/hydration/samples/claim-text/Component.svelte new file mode 100644 index 0000000000..c4a56edceb --- /dev/null +++ b/test/hydration/samples/claim-text/Component.svelte @@ -0,0 +1,5 @@ + + Title + + +
There should be one
diff --git a/test/hydration/samples/claim-text/Layout.svelte b/test/hydration/samples/claim-text/Layout.svelte new file mode 100644 index 0000000000..b37cf18832 --- /dev/null +++ b/test/hydration/samples/claim-text/Layout.svelte @@ -0,0 +1,2 @@ +

This p and the slot below are direct children of the root.

+ diff --git a/test/hydration/samples/claim-text/_after.html b/test/hydration/samples/claim-text/_after.html new file mode 100644 index 0000000000..6f79ed7159 --- /dev/null +++ b/test/hydration/samples/claim-text/_after.html @@ -0,0 +1,3 @@ +

This p and the slot below are direct children of the root.

+ +
There should be one
\ No newline at end of file diff --git a/test/hydration/samples/claim-text/_before.html b/test/hydration/samples/claim-text/_before.html new file mode 100644 index 0000000000..e5653f47fe --- /dev/null +++ b/test/hydration/samples/claim-text/_before.html @@ -0,0 +1,5 @@ +

This p and the slot below are direct children of the root.

+ +
There should be one
+ + \ No newline at end of file diff --git a/test/hydration/samples/claim-text/main.svelte b/test/hydration/samples/claim-text/main.svelte new file mode 100644 index 0000000000..46c001589d --- /dev/null +++ b/test/hydration/samples/claim-text/main.svelte @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file