@@ -243,12 +243,12 @@ type RenderTask = {
243
243
abortSet : Set < Task > , // the abortable set that this task belongs to
244
244
keyPath : Root | KeyNode , // the path of all parent keys currently rendering
245
245
formatContext : FormatContext , // the format's specific context (e.g. HTML/SVG/MathML)
246
- legacyContext : LegacyContext , // the current legacy context that this task is executing in
247
246
context : ContextSnapshot , // the current new context that this task is executing in
248
247
treeContext : TreeContext , // the current tree context that this task is executing in
249
248
componentStack : null | ComponentStackNode , // stack frame description of the currently rendering component
250
249
thenableState : null | ThenableState ,
251
250
isFallback : boolean , // whether this task is rendering inside a fallback tree
251
+ legacyContext : LegacyContext , // the current legacy context that this task is executing in
252
252
// DON'T ANY MORE FIELDS. We at 16 already which otherwise requires converting to a constructor.
253
253
// Consider splitting into multiple objects or consolidating some fields.
254
254
} ;
@@ -272,12 +272,12 @@ type ReplayTask = {
272
272
abortSet : Set < Task > , // the abortable set that this task belongs to
273
273
keyPath : Root | KeyNode , // the path of all parent keys currently rendering
274
274
formatContext : FormatContext , // the format's specific context (e.g. HTML/SVG/MathML)
275
- legacyContext : LegacyContext , // the current legacy context that this task is executing in
276
275
context : ContextSnapshot , // the current new context that this task is executing in
277
276
treeContext : TreeContext , // the current tree context that this task is executing in
278
277
componentStack : null | ComponentStackNode , // stack frame description of the currently rendering component
279
278
thenableState : null | ThenableState ,
280
279
isFallback : boolean , // whether this task is rendering inside a fallback tree
280
+ legacyContext : LegacyContext , // the current legacy context that this task is executing in
281
281
// DON'T ANY MORE FIELDS. We at 16 already which otherwise requires converting to a constructor.
282
282
// Consider splitting into multiple objects or consolidating some fields.
283
283
} ;
@@ -462,11 +462,11 @@ function RequestInstance(
462
462
abortSet ,
463
463
null ,
464
464
rootFormatContext ,
465
- emptyContextObject ,
466
465
rootContextSnapshot ,
467
466
emptyTreeContext ,
468
467
null ,
469
468
false ,
469
+ emptyContextObject ,
470
470
) ;
471
471
pingedTasks . push ( rootTask ) ;
472
472
}
@@ -604,11 +604,11 @@ export function resumeRequest(
604
604
abortSet ,
605
605
null ,
606
606
postponedState . rootFormatContext ,
607
- emptyContextObject ,
608
607
rootContextSnapshot ,
609
608
emptyTreeContext ,
610
609
null ,
611
610
false ,
611
+ emptyContextObject ,
612
612
) ;
613
613
pingedTasks . push ( rootTask ) ;
614
614
return request ;
@@ -630,11 +630,11 @@ export function resumeRequest(
630
630
abortSet ,
631
631
null ,
632
632
postponedState . rootFormatContext ,
633
- emptyContextObject ,
634
633
rootContextSnapshot ,
635
634
emptyTreeContext ,
636
635
null ,
637
636
false ,
637
+ emptyContextObject ,
638
638
) ;
639
639
pingedTasks . push ( rootTask ) ;
640
640
return request ;
@@ -698,19 +698,19 @@ function createRenderTask(
698
698
abortSet : Set < Task > ,
699
699
keyPath : Root | KeyNode ,
700
700
formatContext : FormatContext ,
701
- legacyContext : LegacyContext ,
702
701
context : ContextSnapshot ,
703
702
treeContext : TreeContext ,
704
703
componentStack : null | ComponentStackNode ,
705
704
isFallback : boolean ,
705
+ legacyContext : LegacyContext ,
706
706
) : RenderTask {
707
707
request . allPendingTasks ++ ;
708
708
if ( blockedBoundary === null ) {
709
709
request . pendingRootTasks ++ ;
710
710
} else {
711
711
blockedBoundary . pendingTasks ++ ;
712
712
}
713
- const task : RenderTask = {
713
+ const task : RenderTask = ( {
714
714
replay : null ,
715
715
node,
716
716
childIndex,
@@ -721,13 +721,15 @@ function createRenderTask(
721
721
abortSet,
722
722
keyPath,
723
723
formatContext,
724
- legacyContext ,
725
724
context,
726
725
treeContext,
727
726
componentStack,
728
727
thenableState,
729
728
isFallback,
730
- } ;
729
+ } : any ) ;
730
+ if ( ! disableLegacyContext ) {
731
+ task . legacyContext = legacyContext ;
732
+ }
731
733
abortSet . add ( task ) ;
732
734
return task ;
733
735
}
@@ -743,11 +745,11 @@ function createReplayTask(
743
745
abortSet : Set < Task > ,
744
746
keyPath : Root | KeyNode ,
745
747
formatContext : FormatContext ,
746
- legacyContext : LegacyContext ,
747
748
context : ContextSnapshot ,
748
749
treeContext : TreeContext ,
749
750
componentStack : null | ComponentStackNode ,
750
751
isFallback : boolean ,
752
+ legacyContext : LegacyContext ,
751
753
) : ReplayTask {
752
754
request . allPendingTasks ++ ;
753
755
if ( blockedBoundary === null ) {
@@ -756,7 +758,7 @@ function createReplayTask(
756
758
blockedBoundary . pendingTasks ++ ;
757
759
}
758
760
replay . pendingTasks ++ ;
759
- const task : ReplayTask = {
761
+ const task : ReplayTask = ( {
760
762
replay,
761
763
node,
762
764
childIndex,
@@ -767,13 +769,15 @@ function createReplayTask(
767
769
abortSet,
768
770
keyPath,
769
771
formatContext,
770
- legacyContext,
771
772
context,
772
773
treeContext,
773
774
componentStack,
774
775
thenableState,
775
776
isFallback,
776
- } ;
777
+ } : any ) ;
778
+ if ( ! disableLegacyContext ) {
779
+ task . legacyContext = legacyContext ;
780
+ }
777
781
abortSet . add ( task ) ;
778
782
return task ;
779
783
}
@@ -1188,13 +1192,13 @@ function renderSuspenseBoundary(
1188
1192
fallbackAbortSet ,
1189
1193
fallbackKeyPath ,
1190
1194
task . formatContext ,
1191
- task . legacyContext ,
1192
1195
task . context ,
1193
1196
task . treeContext ,
1194
1197
// This stack should be the Suspense boundary stack because while the fallback is actually a child segment
1195
1198
// of the parent boundary from a component standpoint the fallback is a child of the Suspense boundary itself
1196
1199
suspenseComponentStack ,
1197
1200
true ,
1201
+ ! disableLegacyContext ? task . legacyContext : emptyContextObject ,
1198
1202
) ;
1199
1203
// TODO: This should be queued at a separate lower priority queue so that we only work
1200
1204
// on preparing fallbacks if we don't have any more main content to task on.
@@ -1328,13 +1332,13 @@ function replaySuspenseBoundary(
1328
1332
fallbackAbortSet ,
1329
1333
fallbackKeyPath ,
1330
1334
task . formatContext ,
1331
- task . legacyContext ,
1332
1335
task . context ,
1333
1336
task . treeContext ,
1334
1337
// This stack should be the Suspense boundary stack because while the fallback is actually a child segment
1335
1338
// of the parent boundary from a component standpoint the fallback is a child of the Suspense boundary itself
1336
1339
suspenseComponentStack ,
1337
1340
true ,
1341
+ ! disableLegacyContext ? task . legacyContext : emptyContextObject ,
1338
1342
) ;
1339
1343
// TODO: This should be queued at a separate lower priority queue so that we only work
1340
1344
// on preparing fallbacks if we don't have any more main content to task on.
@@ -3271,13 +3275,13 @@ function spawnNewSuspendedReplayTask(
3271
3275
task . abortSet ,
3272
3276
task . keyPath ,
3273
3277
task . formatContext ,
3274
- task . legacyContext ,
3275
3278
task . context ,
3276
3279
task . treeContext ,
3277
3280
// We pop one task off the stack because the node that suspended will be tried again,
3278
3281
// which will add it back onto the stack.
3279
3282
task . componentStack !== null ? task . componentStack . parent : null ,
3280
3283
task . isFallback ,
3284
+ ! disableLegacyContext ? task . legacyContext : emptyContextObject ,
3281
3285
) ;
3282
3286
3283
3287
const ping = newTask . ping ;
@@ -3317,13 +3321,13 @@ function spawnNewSuspendedRenderTask(
3317
3321
task . abortSet ,
3318
3322
task . keyPath ,
3319
3323
task . formatContext ,
3320
- task . legacyContext ,
3321
3324
task . context ,
3322
3325
task . treeContext ,
3323
3326
// We pop one task off the stack because the node that suspended will be tried again,
3324
3327
// which will add it back onto the stack.
3325
3328
task . componentStack !== null ? task . componentStack . parent : null ,
3326
3329
task . isFallback ,
3330
+ ! disableLegacyContext ? task . legacyContext : emptyContextObject ,
3327
3331
) ;
3328
3332
3329
3333
const ping = newTask . ping ;
@@ -3341,7 +3345,9 @@ function renderNode(
3341
3345
// Snapshot the current context in case something throws to interrupt the
3342
3346
// process.
3343
3347
const previousFormatContext = task . formatContext ;
3344
- const previousLegacyContext = task . legacyContext ;
3348
+ const previousLegacyContext = ! disableLegacyContext
3349
+ ? task . legacyContext
3350
+ : emptyContextObject ;
3345
3351
const previousContext = task . context ;
3346
3352
const previousKeyPath = task . keyPath ;
3347
3353
const previousTreeContext = task . treeContext ;
@@ -3383,7 +3389,9 @@ function renderNode(
3383
3389
// Restore the context. We assume that this will be restored by the inner
3384
3390
// functions in case nothing throws so we don't use "finally" here.
3385
3391
task . formatContext = previousFormatContext ;
3386
- task . legacyContext = previousLegacyContext ;
3392
+ if ( ! disableLegacyContext ) {
3393
+ task . legacyContext = previousLegacyContext ;
3394
+ }
3387
3395
task . context = previousContext ;
3388
3396
task . keyPath = previousKeyPath ;
3389
3397
task . treeContext = previousTreeContext ;
@@ -3435,7 +3443,9 @@ function renderNode(
3435
3443
// Restore the context. We assume that this will be restored by the inner
3436
3444
// functions in case nothing throws so we don't use "finally" here.
3437
3445
task . formatContext = previousFormatContext ;
3438
- task . legacyContext = previousLegacyContext ;
3446
+ if ( ! disableLegacyContext ) {
3447
+ task . legacyContext = previousLegacyContext ;
3448
+ }
3439
3449
task . context = previousContext ;
3440
3450
task . keyPath = previousKeyPath ;
3441
3451
task . treeContext = previousTreeContext ;
@@ -3469,7 +3479,9 @@ function renderNode(
3469
3479
// Restore the context. We assume that this will be restored by the inner
3470
3480
// functions in case nothing throws so we don't use "finally" here.
3471
3481
task . formatContext = previousFormatContext ;
3472
- task . legacyContext = previousLegacyContext ;
3482
+ if ( ! disableLegacyContext ) {
3483
+ task . legacyContext = previousLegacyContext ;
3484
+ }
3473
3485
task . context = previousContext ;
3474
3486
task . keyPath = previousKeyPath ;
3475
3487
task . treeContext = previousTreeContext ;
@@ -3485,7 +3497,9 @@ function renderNode(
3485
3497
// Restore the context. We assume that this will be restored by the inner
3486
3498
// functions in case nothing throws so we don't use "finally" here.
3487
3499
task . formatContext = previousFormatContext ;
3488
- task . legacyContext = previousLegacyContext ;
3500
+ if ( ! disableLegacyContext ) {
3501
+ task . legacyContext = previousLegacyContext ;
3502
+ }
3489
3503
task . context = previousContext ;
3490
3504
task . keyPath = previousKeyPath ;
3491
3505
task . treeContext = previousTreeContext ;
0 commit comments