@@ -26,6 +26,7 @@ import type {OffscreenState} from './ReactFiberOffscreenComponent';
2626import  type  { HookFlags }  from  './ReactHookEffectTags' ; 
2727
2828import  { 
29+   enableCreateEventHandleAPI , 
2930  enableProfilerTimer , 
3031  enableProfilerCommitHooks , 
3132  enableProfilerNestedUpdatePhase , 
@@ -365,12 +366,16 @@ function commitBeforeMutationEffects_begin() {
365366  while  ( nextEffect  !==  null )  { 
366367    const  fiber  =  nextEffect ; 
367368
368-     // TODO: Should wrap this in flags check, too, as optimization 
369-     const  deletions  =  fiber . deletions ; 
370-     if  ( deletions  !==  null )  { 
371-       for  ( let  i  =  0 ;  i  <  deletions . length ;  i ++ )  { 
372-         const  deletion  =  deletions [ i ] ; 
373-         commitBeforeMutationEffectsDeletion ( deletion ) ; 
369+     // This phase is only used for beforeActiveInstanceBlur. 
370+     // Let's skip the whole loop if it's off. 
371+     if  ( enableCreateEventHandleAPI )  { 
372+       // TODO: Should wrap this in flags check, too, as optimization 
373+       const  deletions  =  fiber . deletions ; 
374+       if  ( deletions  !==  null )  { 
375+         for  ( let  i  =  0 ;  i  <  deletions . length ;  i ++ )  { 
376+           const  deletion  =  deletions [ i ] ; 
377+           commitBeforeMutationEffectsDeletion ( deletion ) ; 
378+         } 
374379      } 
375380    } 
376381
@@ -426,16 +431,18 @@ function commitBeforeMutationEffectsOnFiber(finishedWork: Fiber) {
426431  const  current  =  finishedWork . alternate ; 
427432  const  flags  =  finishedWork . flags ; 
428433
429-   if  ( ! shouldFireAfterActiveInstanceBlur  &&  focusedInstanceHandle  !==  null )  { 
430-     // Check to see if the focused element was inside of a hidden (Suspense) subtree. 
431-     // TODO: Move this out of the hot path using a dedicated effect tag. 
432-     if  ( 
433-       finishedWork . tag  ===  SuspenseComponent  && 
434-       isSuspenseBoundaryBeingHidden ( current ,  finishedWork )  && 
435-       doesFiberContain ( finishedWork ,  focusedInstanceHandle ) 
436-     )  { 
437-       shouldFireAfterActiveInstanceBlur  =  true ; 
438-       beforeActiveInstanceBlur ( finishedWork ) ; 
434+   if  ( enableCreateEventHandleAPI )  { 
435+     if  ( ! shouldFireAfterActiveInstanceBlur  &&  focusedInstanceHandle  !==  null )  { 
436+       // Check to see if the focused element was inside of a hidden (Suspense) subtree. 
437+       // TODO: Move this out of the hot path using a dedicated effect tag. 
438+       if  ( 
439+         finishedWork . tag  ===  SuspenseComponent  && 
440+         isSuspenseBoundaryBeingHidden ( current ,  finishedWork )  && 
441+         doesFiberContain ( finishedWork ,  focusedInstanceHandle ) 
442+       )  { 
443+         shouldFireAfterActiveInstanceBlur  =  true ; 
444+         beforeActiveInstanceBlur ( finishedWork ) ; 
445+       } 
439446    } 
440447  } 
441448
@@ -531,13 +538,15 @@ function commitBeforeMutationEffectsOnFiber(finishedWork: Fiber) {
531538} 
532539
533540function  commitBeforeMutationEffectsDeletion ( deletion : Fiber )  { 
534-   // TODO (effects) It would be nice to avoid calling doesFiberContain() 
535-   // Maybe we can repurpose one of the subtreeFlags positions for this instead? 
536-   // Use it to store which part of the tree the focused instance is in? 
537-   // This assumes we can safely determine that instance during the "render" phase. 
538-   if  ( doesFiberContain ( deletion ,  ( ( focusedInstanceHandle : any ) : Fiber ) ) )  { 
539-     shouldFireAfterActiveInstanceBlur  =  true ; 
540-     beforeActiveInstanceBlur ( deletion ) ; 
541+   if  ( enableCreateEventHandleAPI )  { 
542+     // TODO (effects) It would be nice to avoid calling doesFiberContain() 
543+     // Maybe we can repurpose one of the subtreeFlags positions for this instead? 
544+     // Use it to store which part of the tree the focused instance is in? 
545+     // This assumes we can safely determine that instance during the "render" phase. 
546+     if  ( doesFiberContain ( deletion ,  ( ( focusedInstanceHandle : any ) : Fiber ) ) )  { 
547+       shouldFireAfterActiveInstanceBlur  =  true ; 
548+       beforeActiveInstanceBlur ( deletion ) ; 
549+     } 
541550  } 
542551} 
543552
0 commit comments