Skip to content

Commit 0e5adf7

Browse files
committed
fix(hydration): advance cursor past lite-adopted rebuilt root
The new unframed lite path for rebuiltTail cleared the tail marker so sweepRebuiltTail would not discard the adopted node, but never advanced the hydration cursor past that root. clone() parks on the adopted node, and the existing post-body advance only runs when adoptedClose is set. A later sibling therefore hydrated against the node this lite just claimed, potentially discarding or moving it. Track the adopted node as rebuiltOpen and, after the body renders, step the cursor past it when clone() left it parked there—mirroring the stepPastRoot advance that componentSlotImpl already performs for full unframed single-root components.
1 parent 9f28db5 commit 0e5adf7

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11660,6 +11660,9 @@ export function componentSlotLite<P>(
1166011660
// The server node an anchorless call found where its range belonged (first
1166111661
// hydration render only); undefined when it claimed a range or none.
1166211662
let unframed: Node | null | undefined;
11663+
// The unframed server node a rebuilt root left at the cursor (first
11664+
// hydration render only) — consumed by the post-body cursor advance.
11665+
let rebuiltOpen: Node | null = null;
1166311666
if (scope === undefined) {
1166411667
scope = new ScopeImpl(parentScope, parentScope.block);
1166511668
// Lite scope's `block` exposes the host/anchor as the body's DOM context
@@ -11704,6 +11707,7 @@ export function componentSlotLite<P>(
1170411707
} else if (open === hydration.rebuiltTail) {
1170511708
// The body may adopt this unframed server node as its root.
1170611709
hydration.rebuiltTail = null;
11710+
rebuiltOpen = open;
1170711711
}
1170811712
}
1170911713
scope.block = new LiteBlockImpl(host, endMarker, parentScope.block) as unknown as Block;
@@ -11775,6 +11779,8 @@ export function componentSlotLite<P>(
1177511779
// its commitBag insert MOVES the previous sibling's root to the shared
1177611780
// anchor. Mirrors componentSlot's post-render advance.
1177711781
if (hydration !== null && adoptedClose !== null) hydration.node = getNextSibling(adoptedClose);
11782+
else if (hydration !== null && rebuiltOpen !== null && hydration.node === rebuiltOpen)
11783+
hydration.node = getNextSibling(rebuiltOpen);
1177811784
}
1177911785

1178011786
// An anchorless lite call whose server range is missing: render it between

0 commit comments

Comments
 (0)