@@ -2460,14 +2460,6 @@ function trackPostpone(
2460
2460
segment . status = POSTPONED ;
2461
2461
2462
2462
const keyPath = task . keyPath ;
2463
- if ( keyPath === null ) {
2464
- // TODO: This is not really true now because if you postpone in the root component
2465
- // or has a lazy root then that's the root.
2466
- throw new Error (
2467
- 'It should not be possible to postpone at the root. This is a bug in React.' ,
2468
- ) ;
2469
- }
2470
-
2471
2463
const boundary = task . blockedBoundary ;
2472
2464
if ( boundary !== null && boundary . status === PENDING ) {
2473
2465
boundary . status = POSTPONED ;
@@ -2525,37 +2517,53 @@ function trackPostpone(
2525
2517
2526
2518
if ( task . childIndex === - 1 ) {
2527
2519
// Resume starting from directly inside the previous parent element.
2528
- const resumableElement : ReplayNode = [
2529
- keyPath [ 1 ] ,
2530
- keyPath [ 2 ] ,
2531
- ( [ ] : Array < ReplayNode > ) ,
2532
- segment . id ,
2533
- ] ;
2534
- addToReplayParent ( resumableElement , keyPath [ 0 ] , trackedPostpones ) ;
2535
- } else {
2536
- const workingMap = trackedPostpones . workingMap ;
2537
- let resumableNode = workingMap . get ( keyPath ) ;
2538
- let slots ;
2539
- if ( resumableNode === undefined ) {
2540
- slots = ( { } : { [ index : number ] : number } ) ;
2541
- resumableNode = ( [
2520
+ if ( keyPath === null ) {
2521
+ trackedPostpones . rootSlots = segment . id ;
2522
+ } else {
2523
+ const resumableElement : ReplayNode = [
2542
2524
keyPath [ 1 ] ,
2543
2525
keyPath [ 2 ] ,
2544
2526
( [ ] : Array < ReplayNode > ) ,
2545
- slots ,
2546
- ] : ReplayNode ) ;
2547
- workingMap . set ( keyPath , resumableNode ) ;
2548
- addToReplayParent ( resumableNode , keyPath [ 0 ] , trackedPostpones ) ;
2549
- } else {
2550
- slots = resumableNode [ 3 ] ;
2527
+ segment . id ,
2528
+ ] ;
2529
+ addToReplayParent ( resumableElement , keyPath [ 0 ] , trackedPostpones ) ;
2530
+ }
2531
+ } else {
2532
+ let slots ;
2533
+ if ( keyPath === null ) {
2534
+ slots = trackedPostpones . rootSlots ;
2551
2535
if ( slots === null ) {
2552
- slots = resumableNode [ 3 ] = ( { } : { [ index : number ] : number } ) ;
2536
+ slots = trackedPostpones . rootSlots = ( { } : { [ index : number ] : number } ) ;
2553
2537
} else if ( typeof slots === 'number' ) {
2554
2538
throw new Error (
2555
2539
'It should not be possible to postpone both at the root of an element ' +
2556
2540
'as well as a slot below. This is a bug in React.' ,
2557
2541
) ;
2558
2542
}
2543
+ } else {
2544
+ const workingMap = trackedPostpones . workingMap ;
2545
+ let resumableNode = workingMap . get ( keyPath ) ;
2546
+ if ( resumableNode === undefined ) {
2547
+ slots = ( { } : { [ index : number ] : number } ) ;
2548
+ resumableNode = ( [
2549
+ keyPath [ 1 ] ,
2550
+ keyPath [ 2 ] ,
2551
+ ( [ ] : Array < ReplayNode > ) ,
2552
+ slots ,
2553
+ ] : ReplayNode ) ;
2554
+ workingMap . set ( keyPath , resumableNode ) ;
2555
+ addToReplayParent ( resumableNode , keyPath [ 0 ] , trackedPostpones ) ;
2556
+ } else {
2557
+ slots = resumableNode [ 3 ] ;
2558
+ if ( slots === null ) {
2559
+ slots = resumableNode [ 3 ] = ( { } : { [ index : number ] : number } ) ;
2560
+ } else if ( typeof slots === 'number' ) {
2561
+ throw new Error (
2562
+ 'It should not be possible to postpone both at the root of an element ' +
2563
+ 'as well as a slot below. This is a bug in React.' ,
2564
+ ) ;
2565
+ }
2566
+ }
2559
2567
}
2560
2568
slots [ task . childIndex ] = segment . id ;
2561
2569
}
0 commit comments