Skip to content

Commit b003c91

Browse files
committed
fix(octane): retire all list-clear rows before any row's cleanups run
batchClearItems interleaved per-row retirement with per-row unmount, so an earlier row's layout cleanup could dispatch focus events on hosts in later rows that had not yet been retired. Split into two passes: retire every row's host range first, then unmount all rows.
1 parent 008b974 commit b003c91

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46519,13 +46519,21 @@ function batchClearItems(
4651946519
const retire = renderingFocus !== null || !inFlush;
4652046520
TEARDOWN_DEPTH++;
4652146521
try {
46522+
// Retire every row's hosts BEFORE any row's cleanups run: an earlier
46523+
// row's layout cleanup can move focus, which dispatches on a later row's
46524+
// hosts. If those hosts are not yet retired, the handler runs against a
46525+
// scope the clear is about to dispose.
46526+
if (retire) {
46527+
for (let b: Block | null = state.head; b !== null; b = b.nextSibling) {
46528+
retireHostRange(b.startMarker, b.endMarker);
46529+
}
46530+
}
4652246531
// Dispose the items before their DOM leaves, like every other deletion:
4652346532
// cleanups observe attached hosts. Walk the intrusive item chain (head →
4652446533
// nextSibling) rather than the Map's iterator: zero allocation and a
4652546534
// monomorphic pointer chase. Callers reset head/tail only AFTER this returns,
4652646535
// so the chain still covers exactly the old items here.
4652746536
for (let b: Block | null = state.head; b !== null; b = b.nextSibling) {
46528-
if (retire) retireHostRange(b.startMarker, b.endMarker);
4652946537
if (b.cleanups !== null || b.children !== null || b._slots !== null) {
4653046538
unmountBlock(b, false);
4653146539
} else {

0 commit comments

Comments
 (0)