Skip to content

Commit 5bdf044

Browse files
committed
fix(hydration): guard unframed cursor stamp, detached endMarker, and markerless abort start
- Unframed root stamp: skip isBlockClose cursors so the fresh root is detected via freshAfter instead of stamping the parent's close marker. - rebuiltPosition: fall back to null when endMarker has been detached from parent (self-marked element removed by a retry's discardCursor). - Markerless abort: store contentBefore (the cursor's previousSibling) so the sweep covers the adopted prefix, not just after.previousSibling.
1 parent 2efce03 commit 5bdf044

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19896,9 +19896,9 @@ class HydrationCapability {
1989619896
*/
1989719897
rebuiltPosition(root: Node, parent: Node, end: Node | null): Node | null {
1989819898
const next = this.rebuiltTail;
19899-
return root === this.rebuiltRoot && next !== null && domNode(next).parentNode === parent
19900-
? next
19901-
: end;
19899+
if (root === this.rebuiltRoot && next !== null && domNode(next).parentNode === parent)
19900+
return next;
19901+
return end !== null && (STAGED_DOM?.view(end) ?? end).parentNode !== parent ? null : end;
1990219902
}
1990319903

1990419904
/**
@@ -31768,7 +31768,8 @@ function componentSlotImpl(
3176831768
if (
3176931769
hydration !== null &&
3177031770
hydrationCursor !== null &&
31771-
(STAGED_DOM?.view(hydrationCursor) ?? hydrationCursor).parentNode === domParent
31771+
(STAGED_DOM?.view(hydrationCursor) ?? hydrationCursor).parentNode === domParent &&
31772+
!isBlockClose(hydrationCursor)
3177231773
) {
3177331774
// An unframed single-root return adopts the element that was already
3177431775
// present, so the client-mount before/after probe cannot observe an
@@ -41953,7 +41954,7 @@ function renderBranchSlot(
4195341954
env,
4195441955
);
4195541956
state.block = b;
41956-
state.markerlessBefore = before;
41957+
state.markerlessBefore = contentBefore;
4195741958
try {
4195841959
if (replacing) hydration!.suspend(() => renderBlock(b));
4195941960
else renderBlock(b);

0 commit comments

Comments
 (0)