@@ -741,9 +741,10 @@ const HTML_COLGROUP_MODE = 9;
741
741
742
742
type InsertionMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ;
743
743
744
- const NO_SCOPE = /* */ 0b00 ;
745
- const NOSCRIPT_SCOPE = /* */ 0b01 ;
746
- const PICTURE_SCOPE = /* */ 0b10 ;
744
+ const NO_SCOPE = /* */ 0b000 ;
745
+ const NOSCRIPT_SCOPE = /* */ 0b001 ;
746
+ const PICTURE_SCOPE = /* */ 0b010 ;
747
+ const FALLBACK_SCOPE = /* */ 0b100 ;
747
748
748
749
// Lets us keep track of contextual state and pick it back up after suspending.
749
750
export type FormatContext = {
@@ -754,7 +755,7 @@ export type FormatContext = {
754
755
755
756
function createFormatContext (
756
757
insertionMode : InsertionMode ,
757
- selectedValue : null | string ,
758
+ selectedValue : null | string | Array < string > ,
758
759
tagScope : number ,
759
760
) : FormatContext {
760
761
return {
@@ -864,6 +865,22 @@ export function getChildFormatContext(
864
865
return parentContext ;
865
866
}
866
867
868
+ export function getSuspenseFallbackFormatContext (
869
+ parentContext : FormatContext ,
870
+ ) : FormatContext {
871
+ return createFormatContext (
872
+ parentContext . insertionMode ,
873
+ parentContext . selectedValue ,
874
+ parentContext . tagScope | FALLBACK_SCOPE ,
875
+ ) ;
876
+ }
877
+
878
+ export function getSuspenseContentFormatContext (
879
+ parentContext : FormatContext ,
880
+ ) : FormatContext {
881
+ return parentContext ;
882
+ }
883
+
867
884
export function isPreambleContext ( formatContext : FormatContext ) : boolean {
868
885
return formatContext . insertionMode === HTML_HEAD_MODE ;
869
886
}
@@ -2511,12 +2528,12 @@ function pushMeta(
2511
2528
props : Object ,
2512
2529
renderState : RenderState ,
2513
2530
textEmbedded : boolean ,
2514
- insertionMode : InsertionMode ,
2515
- noscriptTagInScope : boolean ,
2516
- isFallback : boolean ,
2531
+ formatContext : FormatContext ,
2517
2532
) : null {
2533
+ const noscriptTagInScope = formatContext . tagScope & NOSCRIPT_SCOPE ;
2534
+ const isFallback = formatContext . tagScope & FALLBACK_SCOPE ;
2518
2535
if (
2519
- insertionMode === SVG_MODE ||
2536
+ formatContext . insertionMode === SVG_MODE ||
2520
2537
noscriptTagInScope ||
2521
2538
props . itemProp != null
2522
2539
) {
@@ -2559,15 +2576,15 @@ function pushLink(
2559
2576
renderState : RenderState ,
2560
2577
hoistableState : null | HoistableState ,
2561
2578
textEmbedded : boolean ,
2562
- insertionMode : InsertionMode ,
2563
- noscriptTagInScope : boolean ,
2564
- isFallback : boolean ,
2579
+ formatContext : FormatContext ,
2565
2580
) : null {
2581
+ const noscriptTagInScope = formatContext . tagScope & NOSCRIPT_SCOPE ;
2582
+ const isFallback = formatContext . tagScope & FALLBACK_SCOPE ;
2566
2583
const rel = props . rel ;
2567
2584
const href = props . href ;
2568
2585
const precedence = props . precedence ;
2569
2586
if (
2570
- insertionMode === SVG_MODE ||
2587
+ formatContext . insertionMode === SVG_MODE ||
2571
2588
noscriptTagInScope ||
2572
2589
props . itemProp != null ||
2573
2590
typeof rel !== 'string' ||
@@ -2765,9 +2782,9 @@ function pushStyle(
2765
2782
renderState : RenderState ,
2766
2783
hoistableState : null | HoistableState ,
2767
2784
textEmbedded : boolean ,
2768
- insertionMode : InsertionMode ,
2769
- noscriptTagInScope : boolean ,
2785
+ formatContext : FormatContext ,
2770
2786
) : ReactNodeList {
2787
+ const noscriptTagInScope = formatContext . tagScope & NOSCRIPT_SCOPE ;
2771
2788
if ( __DEV__ ) {
2772
2789
if ( hasOwnProperty . call ( props , 'children' ) ) {
2773
2790
const children = props . children ;
@@ -2801,7 +2818,7 @@ function pushStyle(
2801
2818
const href = props . href ;
2802
2819
2803
2820
if (
2804
- insertionMode === SVG_MODE ||
2821
+ formatContext . insertionMode === SVG_MODE ||
2805
2822
noscriptTagInScope ||
2806
2823
props . itemProp != null ||
2807
2824
typeof precedence !== 'string' ||
@@ -2984,16 +3001,18 @@ function pushImg(
2984
3001
props : Object ,
2985
3002
resumableState : ResumableState ,
2986
3003
renderState : RenderState ,
2987
- pictureOrNoScriptTagInScope : boolean ,
3004
+ formatContext : FormatContext ,
2988
3005
) : null {
3006
+ const pictureOrNoScriptTagInScope =
3007
+ formatContext . tagScope & ( PICTURE_SCOPE | NOSCRIPT_SCOPE ) ;
2989
3008
const { src , srcSet } = props ;
2990
3009
if (
2991
3010
props . loading !== 'lazy ' &&
2992
3011
( src || srcSet ) &&
2993
3012
( typeof src === 'string' || src == null ) &&
2994
3013
( typeof srcSet === 'string' || srcSet == null ) &&
2995
3014
props . fetchPriority !== 'low' &&
2996
- pictureOrNoScriptTagInScope === false &&
3015
+ ! pictureOrNoScriptTagInScope &&
2997
3016
// We exclude data URIs in src and srcSet since these should not be preloaded
2998
3017
! (
2999
3018
typeof src === 'string' &&
@@ -3190,10 +3209,10 @@ function pushTitle(
3190
3209
target : Array < Chunk | PrecomputedChunk > ,
3191
3210
props : Object ,
3192
3211
renderState : RenderState ,
3193
- insertionMode : InsertionMode ,
3194
- noscriptTagInScope : boolean ,
3195
- isFallback : boolean ,
3212
+ formatContext : FormatContext ,
3196
3213
) : ReactNodeList {
3214
+ const noscriptTagInScope = formatContext . tagScope & NOSCRIPT_SCOPE ;
3215
+ const isFallback = formatContext . tagScope & FALLBACK_SCOPE ;
3197
3216
if ( __DEV__ ) {
3198
3217
if ( hasOwnProperty . call ( props , 'children' ) ) {
3199
3218
const children = props . children ;
@@ -3243,7 +3262,7 @@ function pushTitle(
3243
3262
}
3244
3263
3245
3264
if (
3246
- insertionMode !== SVG_MODE &&
3265
+ formatContext . insertionMode !== SVG_MODE &&
3247
3266
! noscriptTagInScope &&
3248
3267
props . itemProp == null
3249
3268
) {
@@ -3320,9 +3339,9 @@ function pushStartHead(
3320
3339
props : Object ,
3321
3340
renderState : RenderState ,
3322
3341
preambleState : null | PreambleState ,
3323
- insertionMode : InsertionMode ,
3342
+ formatContext : FormatContext ,
3324
3343
) : ReactNodeList {
3325
- if ( insertionMode < HTML_MODE ) {
3344
+ if ( formatContext . insertionMode < HTML_MODE ) {
3326
3345
// This <head> is the Document.head and should be part of the preamble
3327
3346
const preamble = preambleState || renderState . preamble ;
3328
3347
@@ -3349,9 +3368,9 @@ function pushStartBody(
3349
3368
props : Object ,
3350
3369
renderState : RenderState ,
3351
3370
preambleState : null | PreambleState ,
3352
- insertionMode : InsertionMode ,
3371
+ formatContext : FormatContext ,
3353
3372
) : ReactNodeList {
3354
- if ( insertionMode < HTML_MODE ) {
3373
+ if ( formatContext . insertionMode < HTML_MODE ) {
3355
3374
// This <body> is the Document.body
3356
3375
const preamble = preambleState || renderState . preamble ;
3357
3376
@@ -3378,9 +3397,9 @@ function pushStartHtml(
3378
3397
props : Object ,
3379
3398
renderState : RenderState ,
3380
3399
preambleState : null | PreambleState ,
3381
- insertionMode : InsertionMode ,
3400
+ formatContext : FormatContext ,
3382
3401
) : ReactNodeList {
3383
- if ( insertionMode === ROOT_HTML_MODE ) {
3402
+ if ( formatContext . insertionMode === ROOT_HTML_MODE ) {
3384
3403
// This <html> is the Document.documentElement
3385
3404
const preamble = preambleState || renderState . preamble ;
3386
3405
@@ -3408,9 +3427,9 @@ function pushScript(
3408
3427
resumableState : ResumableState ,
3409
3428
renderState : RenderState ,
3410
3429
textEmbedded : boolean ,
3411
- insertionMode : InsertionMode ,
3412
- noscriptTagInScope : boolean ,
3430
+ formatContext : FormatContext ,
3413
3431
) : null {
3432
+ const noscriptTagInScope = formatContext . tagScope & NOSCRIPT_SCOPE ;
3414
3433
const asyncProp = props . async ;
3415
3434
if (
3416
3435
typeof props . src !== 'string' ||
@@ -3422,7 +3441,7 @@ function pushScript(
3422
3441
) ||
3423
3442
props . onLoad ||
3424
3443
props . onError ||
3425
- insertionMode === SVG_MODE ||
3444
+ formatContext . insertionMode === SVG_MODE ||
3426
3445
noscriptTagInScope ||
3427
3446
props . itemProp != null
3428
3447
) {
@@ -3790,7 +3809,6 @@ export function pushStartInstance(
3790
3809
hoistableState : null | HoistableState ,
3791
3810
formatContext : FormatContext ,
3792
3811
textEmbedded : boolean ,
3793
- isFallback : boolean ,
3794
3812
) : ReactNodeList {
3795
3813
if ( __DEV__ ) {
3796
3814
validateARIAProperties ( type , props ) ;
@@ -3857,14 +3875,7 @@ export function pushStartInstance(
3857
3875
case 'object' :
3858
3876
return pushStartObject ( target , props ) ;
3859
3877
case 'title' :
3860
- return pushTitle (
3861
- target ,
3862
- props ,
3863
- renderState ,
3864
- formatContext . insertionMode ,
3865
- ! ! ( formatContext . tagScope & NOSCRIPT_SCOPE ) ,
3866
- isFallback ,
3867
- ) ;
3878
+ return pushTitle ( target , props , renderState , formatContext ) ;
3868
3879
case 'link' :
3869
3880
return pushLink (
3870
3881
target ,
@@ -3873,9 +3884,7 @@ export function pushStartInstance(
3873
3884
renderState ,
3874
3885
hoistableState ,
3875
3886
textEmbedded ,
3876
- formatContext . insertionMode ,
3877
- ! ! ( formatContext . tagScope & NOSCRIPT_SCOPE ) ,
3878
- isFallback ,
3887
+ formatContext ,
3879
3888
) ;
3880
3889
case 'script' :
3881
3890
return pushScript (
@@ -3884,8 +3893,7 @@ export function pushStartInstance(
3884
3893
resumableState ,
3885
3894
renderState ,
3886
3895
textEmbedded ,
3887
- formatContext . insertionMode ,
3888
- ! ! ( formatContext . tagScope & NOSCRIPT_SCOPE ) ,
3896
+ formatContext ,
3889
3897
) ;
3890
3898
case 'style' :
3891
3899
return pushStyle (
@@ -3895,32 +3903,17 @@ export function pushStartInstance(
3895
3903
renderState ,
3896
3904
hoistableState ,
3897
3905
textEmbedded ,
3898
- formatContext . insertionMode ,
3899
- ! ! ( formatContext . tagScope & NOSCRIPT_SCOPE ) ,
3906
+ formatContext ,
3900
3907
) ;
3901
3908
case 'meta' :
3902
- return pushMeta (
3903
- target ,
3904
- props ,
3905
- renderState ,
3906
- textEmbedded ,
3907
- formatContext . insertionMode ,
3908
- ! ! ( formatContext . tagScope & NOSCRIPT_SCOPE ) ,
3909
- isFallback ,
3910
- ) ;
3909
+ return pushMeta ( target , props , renderState , textEmbedded , formatContext ) ;
3911
3910
// Newline eating tags
3912
3911
case 'listing' :
3913
3912
case 'pre' : {
3914
3913
return pushStartPreformattedElement ( target , props , type ) ;
3915
3914
}
3916
3915
case 'img' : {
3917
- return pushImg (
3918
- target ,
3919
- props ,
3920
- resumableState ,
3921
- renderState ,
3922
- ! ! ( formatContext . tagScope & ( PICTURE_SCOPE | NOSCRIPT_SCOPE ) ) ,
3923
- ) ;
3916
+ return pushImg ( target , props , resumableState , renderState , formatContext ) ;
3924
3917
}
3925
3918
// Omitted close tags
3926
3919
case 'base' :
@@ -3955,23 +3948,23 @@ export function pushStartInstance(
3955
3948
props ,
3956
3949
renderState ,
3957
3950
preambleState ,
3958
- formatContext . insertionMode ,
3951
+ formatContext ,
3959
3952
) ;
3960
3953
case 'body' :
3961
3954
return pushStartBody (
3962
3955
target ,
3963
3956
props ,
3964
3957
renderState ,
3965
3958
preambleState ,
3966
- formatContext . insertionMode ,
3959
+ formatContext ,
3967
3960
) ;
3968
3961
case 'html' : {
3969
3962
return pushStartHtml (
3970
3963
target ,
3971
3964
props ,
3972
3965
renderState ,
3973
3966
preambleState ,
3974
- formatContext . insertionMode ,
3967
+ formatContext ,
3975
3968
) ;
3976
3969
}
3977
3970
default : {
0 commit comments