Skip to content

Commit 6df886d

Browse files
committed
fix(octane): use owning block for disposal checks and retire lite arms in return slots
Two fixes for lite control-flow arms: 1. renderBranchSlot's post-teardown guards checked parentBlock.disposed, but when a nested @if/@switch sits inside a lite arm, parentBlock is a LiteBlockImpl which has no disposed field. The guard never fired, letting the incoming arm mount into an already-unmounted tree. Compute owningBlock(parentBlock) once per swap and check its disposed flag. 2. disposeReturnSlot updated its first/last snapshot to include the lite arm's stand-in, but retireRootBlock was still called only on state.block ?? state.portal?.block, skipping the lite arm's stand-in. Add state.lite?.block to the retirement chain.
1 parent dc4812a commit 6df886d

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12829,7 +12829,7 @@ function disposeReturnSlot(block: Block, state: any): void {
1282912829
: (STAGED_DOM?.view(parent) ?? parent).lastChild,
1283012830
borrowed ? end : ((STAGED_DOM?.view(last) ?? last)?.nextSibling ?? null),
1283112831
);
12832-
const retiredBlock = state.block ?? state.portal?.block;
12832+
const retiredBlock = state.block ?? state.lite?.block ?? state.portal?.block;
1283312833
if (retiredBlock != null) retireRootBlock(retiredBlock);
1283412834
if (state.forSlot != null) {
1283512835
for (let item = state.forSlot.head; item !== null; item = item.nextSibling) {
@@ -45524,6 +45524,7 @@ function renderBranchSlot(
4552445524
}
4552545525
}
4552645526
const swapDriver = TRANSITION_SWAP_DRIVER;
45527+
const disposeTarget = owningBlock(parentBlock);
4552745528
const transitionMode = parentBlock.currentRenderMode === 'transition';
4552845529
const committedSuspense =
4552945530
swapDriver !== null &&
@@ -45552,7 +45553,7 @@ function renderBranchSlot(
4555245553
state.block = null;
4555345554
state.unfinalized = false;
4555445555
unmountBlock(pending, false);
45555-
if (parentBlock.disposed) return;
45556+
if (disposeTarget.disposed) return;
4555645557
while (node !== null && node !== provisionalAfter) {
4555745558
const nextNode = getNextSibling(node);
4555845559
if ((STAGED_DOM?.view(node) ?? node).parentNode === domParent)
@@ -45564,7 +45565,7 @@ function renderBranchSlot(
4556445565
provisionalAfter = state.lite.block.endMarker;
4556545566
state.unfinalized = false;
4556645567
unmountLiteArm(state, false);
45567-
if (parentBlock.disposed) return;
45568+
if (disposeTarget.disposed) return;
4556845569
}
4556945570
// A markerless branch may share its host boundary with a nested sole-root
4557045571
// branch. The nested branch updates Block markers when it replaces that
@@ -45790,7 +45791,7 @@ function renderBranchSlot(
4579045791
STAGED_DOM?.view(oldEnd as ChildNode | null) ?? (oldEnd as ChildNode | null)
4579145792
)?.remove();
4579245793
}
45793-
if (parentBlock.disposed || state.block !== r.wip.block || r.wip.block.disposed) return;
45794+
if (disposeTarget.disposed || state.block !== r.wip.block || r.wip.block.disposed) return;
4579445795
return;
4579545796
}
4579645797
}
@@ -45805,11 +45806,11 @@ function renderBranchSlot(
4580545806
const oldBoundaryShared = sharesBlockBoundary(parentBlock, oldBlockStart, oldBlockEnd);
4580645807
if (state.block) {
4580745808
unmountBlock(state.block);
45808-
if (parentBlock.disposed) return;
45809+
if (disposeTarget.disposed) return;
4580945810
state.block = null;
4581045811
} else if (state.lite !== null) {
4581145812
unmountLiteArm(state, true);
45812-
if (parentBlock.disposed) return;
45813+
if (disposeTarget.disposed) return;
4581345814
}
4581445815
state.branch = next;
4581545816
if (state.start === null && body !== null && oldBoundaryShared) {

0 commit comments

Comments
 (0)