@@ -3216,7 +3216,7 @@ body {
32163216 ) ;
32173217 } ) ;
32183218
3219- it ( 'can interrupt a suspended commit with a new transition ' , async ( ) => {
3219+ it ( 'can start a new suspended commit after a previous one finishes ' , async ( ) => {
32203220 function App ( { children} ) {
32213221 return (
32223222 < html >
@@ -3225,66 +3225,81 @@ body {
32253225 ) ;
32263226 }
32273227 const root = ReactDOMClient . createRoot ( document ) ;
3228- root . render ( < App > (empty)</ App > ) ;
3229-
3230- // Start a transition to "A"
3228+ root . render ( < App /> ) ;
32313229 React . startTransition ( ( ) => {
32323230 root . render (
32333231 < App >
3234- A
3235- < link rel = "stylesheet" href = "A " precedence = "default" />
3232+ hello
3233+ < link rel = "stylesheet" href = "foo " precedence = "default" />
32363234 </ App > ,
32373235 ) ;
32383236 } ) ;
32393237 await waitForAll ( [ ] ) ;
3240-
3241- // "A" hasn't loaded yet, so we remain on the initial UI. Its preload
3242- // has been inserted into the head, though.
32433238 expect ( getMeaningfulChildren ( document ) ) . toEqual (
32443239 < html >
32453240 < head >
3246- < link rel = "preload" href = "A " as = "style" />
3241+ < link rel = "preload" href = "foo " as = "style" />
32473242 </ head >
3248- < body > (empty) </ body >
3243+ < body / >
32493244 </ html > ,
32503245 ) ;
32513246
3252- // Interrupt the "A" transition with a new one, "B"
32533247 React . startTransition ( ( ) => {
32543248 root . render (
32553249 < App >
3256- B
3257- < link rel = "stylesheet" href = "B" precedence = "default" />
3250+ hello2
3251+ { null }
3252+ < link rel = "stylesheet" href = "bar" precedence = "default" />
32583253 </ App > ,
32593254 ) ;
32603255 } ) ;
32613256 await waitForAll ( [ ] ) ;
3257+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
3258+ < html >
3259+ < head >
3260+ < link rel = "preload" href = "foo" as = "style" />
3261+ </ head >
3262+ < body />
3263+ </ html > ,
3264+ ) ;
32623265
3263- // Still on the initial UI because "B" hasn't loaded, but its preload
3264- // is now in the head, too.
3266+ loadPreloads ( ) ;
3267+ loadStylesheets ( ) ;
3268+ assertLog ( [ 'load preload: foo' , 'load stylesheet: foo' ] ) ;
32653269 expect ( getMeaningfulChildren ( document ) ) . toEqual (
32663270 < html >
32673271 < head >
3268- < link rel = "preload " href = "A" as = "style " />
3269- < link rel = "preload" href = "B " as = "style" />
3272+ < link rel = "stylesheet " href = "foo" data-precedence = "default " />
3273+ < link rel = "preload" href = "foo " as = "style" />
32703274 </ head >
3271- < body > (empty) </ body >
3275+ < body > hello </ body >
32723276 </ html > ,
32733277 ) ;
32743278
3275- // Finish loading
3279+ // The second update should process now
3280+ await waitForAll ( [ ] ) ;
3281+ expect ( getMeaningfulChildren ( document ) ) . toEqual (
3282+ < html >
3283+ < head >
3284+ < link rel = "stylesheet" href = "foo" data-precedence = "default" />
3285+ < link rel = "preload" href = "foo" as = "style" />
3286+ < link rel = "preload" href = "bar" as = "style" />
3287+ </ head >
3288+ < body > hello</ body >
3289+ </ html > ,
3290+ ) ;
32763291 loadPreloads ( ) ;
32773292 loadStylesheets ( ) ;
3278- assertLog ( [ 'load preload: A' , 'load preload: B' , 'load stylesheet: B' ] ) ;
3279- // The "B" transition has finished.
3293+ assertLog ( [ 'load preload: bar' , 'load stylesheet: bar' ] ) ;
32803294 expect ( getMeaningfulChildren ( document ) ) . toEqual (
32813295 < html >
32823296 < head >
3283- < link rel = "stylesheet" href = "B" data-precedence = "default" />
3284- < link rel = "preload" href = "A" as = "style" />
3285- < link rel = "preload" href = "B" as = "style" />
3297+ < link rel = "stylesheet" href = "foo" data-precedence = "default" />
3298+ < link rel = "stylesheet" href = "bar" data-precedence = "default" />
3299+ < link rel = "preload" href = "foo" as = "style" />
3300+ < link rel = "preload" href = "bar" as = "style" />
32863301 </ head >
3287- < body > B </ body >
3302+ < body > hello2 </ body >
32883303 </ html > ,
32893304 ) ;
32903305 } ) ;
0 commit comments