@@ -2442,27 +2442,29 @@ export function writeEarlyPreamble(
24422442 // If we emitted a preamble early it will have flushed <html> and <head>.
24432443 // We check that we haven't flushed anything yet which is equivalent
24442444 // to checking whether we have not flushed an <html> or <head>
2445- if ( responseState . flushed === NONE && responseState . rendered !== NONE ) {
2446- let i = 0 ;
2447- const { htmlChunks , headChunks } = responseState ;
2448- if ( htmlChunks . length ) {
2449- for ( i = 0 ; i < htmlChunks . length ; i ++ ) {
2450- writeChunk ( destination , htmlChunks [ i ] ) ;
2445+ if ( responseState . rendered !== NONE ) {
2446+ if ( responseState . flushed === NONE ) {
2447+ let i = 0 ;
2448+ const { htmlChunks , headChunks } = responseState ;
2449+ if ( htmlChunks . length ) {
2450+ for ( i = 0 ; i < htmlChunks . length ; i ++ ) {
2451+ writeChunk ( destination , htmlChunks [ i ] ) ;
2452+ }
2453+ } else {
2454+ writeChunk ( destination , DOCTYPE ) ;
2455+ writeChunk ( destination , startChunkForTag ( 'html' ) ) ;
2456+ writeChunk ( destination , endOfStartTag ) ;
24512457 }
2452- } else {
2453- writeChunk ( destination , DOCTYPE ) ;
2454- writeChunk ( destination , startChunkForTag ( 'html' ) ) ;
2455- writeChunk ( destination , endOfStartTag ) ;
2456- }
2457- if ( headChunks . length ) {
2458- for ( i = 0 ; i < headChunks . length ; i ++ ) {
2459- writeChunk ( destination , headChunks [ i ] ) ;
2458+ if ( headChunks . length ) {
2459+ for ( i = 0 ; i < headChunks . length ; i ++ ) {
2460+ writeChunk ( destination , headChunks [ i ] ) ;
2461+ }
2462+ } else {
2463+ writeChunk ( destination , startChunkForTag ( 'head' ) ) ;
2464+ writeChunk ( destination , endOfStartTag ) ;
24602465 }
2461- } else {
2462- writeChunk ( destination , startChunkForTag ( 'head' ) ) ;
2463- writeChunk ( destination , endOfStartTag ) ;
2466+ responseState . flushed |= HTML | HEAD ;
24642467 }
2465- responseState . flushed |= HTML | HEAD ;
24662468
24672469 return writeEarlyResources (
24682470 destination ,
@@ -2587,14 +2589,16 @@ export function prepareForFallback(responseState: ResponseState): void {
25872589 if ( __DEV__ ) {
25882590 ( responseState : any ) . inFallbackDEV = true ;
25892591 }
2590- // This function would ideally check somethign to see whether embedding
2591- // was required however at the moment the only time we use a Request Fallback
2592- // is when we use renderIntoDocument which is the only variant where which
2593- // utilizes fallback children. We assume we're in that mode if this function
2594- // is called and update the requirement accordingly
2592+ // Reset rendered states
25952593 responseState . htmlChunks = [ ] ;
25962594 responseState . headChunks = [ ] ;
25972595 responseState . rendered = NONE ;
2596+
2597+ // Move fallback bootstrap to bootstrap if configured
2598+ const fallbackBootstrapChunks = responseState . fallbackBootstrapChunks ;
2599+ if ( fallbackBootstrapChunks && fallbackBootstrapChunks . length ) {
2600+ responseState . bootstrapChunks = fallbackBootstrapChunks ;
2601+ }
25982602}
25992603
26002604export function writeCompletedRoot (
0 commit comments