@@ -14,10 +14,7 @@ import type {EventSystemFlags} from './EventSystemFlags';
1414import type { FiberRoot } from 'react-reconciler/src/ReactInternalTypes' ;
1515import type { EventPriority } from 'react-reconciler/src/ReactEventPriorities' ;
1616
17- import {
18- enableSelectiveHydration ,
19- enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay ,
20- } from 'shared/ReactFeatureFlags' ;
17+ import { enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay } from 'shared/ReactFeatureFlags' ;
2118import {
2219 unstable_scheduleCallback as scheduleCallback ,
2320 unstable_NormalPriority as NormalPriority ,
@@ -204,27 +201,25 @@ export function queueDiscreteEvent(
204201 nativeEvent ,
205202 ) ;
206203 queuedDiscreteEvents . push ( queuedEvent ) ;
207- if ( enableSelectiveHydration ) {
208- if ( queuedDiscreteEvents . length === 1 ) {
209- // If this was the first discrete event, we might be able to
210- // synchronously unblock it so that preventDefault still works.
211- while ( queuedEvent . blockedOn !== null ) {
212- const fiber = getInstanceFromNode ( queuedEvent . blockedOn ) ;
213- if ( fiber === null ) {
214- break ;
215- }
216- attemptSynchronousHydration ( fiber ) ;
217- if ( queuedEvent . blockedOn === null ) {
218- // We got unblocked by hydration. Let's try again.
219- replayUnblockedEvents ( ) ;
220- // If we're reblocked, on an inner boundary, we might need
221- // to attempt hydrating that one.
222- continue ;
223- } else {
224- // We're still blocked from hydration, we have to give up
225- // and replay later.
226- break ;
227- }
204+ if ( queuedDiscreteEvents . length === 1 ) {
205+ // If this was the first discrete event, we might be able to
206+ // synchronously unblock it so that preventDefault still works.
207+ while ( queuedEvent . blockedOn !== null ) {
208+ const fiber = getInstanceFromNode ( queuedEvent . blockedOn ) ;
209+ if ( fiber === null ) {
210+ break ;
211+ }
212+ attemptSynchronousHydration ( fiber ) ;
213+ if ( queuedEvent . blockedOn === null ) {
214+ // We got unblocked by hydration. Let's try again.
215+ replayUnblockedEvents ( ) ;
216+ // If we're reblocked, on an inner boundary, we might need
217+ // to attempt hydrating that one.
218+ continue ;
219+ } else {
220+ // We're still blocked from hydration, we have to give up
221+ // and replay later.
222+ break ;
228223 }
229224 }
230225 }
@@ -428,33 +423,31 @@ function attemptExplicitHydrationTarget(
428423}
429424
430425export function queueExplicitHydrationTarget ( target : Node ) : void {
431- if ( enableSelectiveHydration ) {
432- // TODO: This will read the priority if it's dispatched by the React
433- // event system but not native events. Should read window.event.type, like
434- // we do for updates (getCurrentEventPriority).
435- const updatePriority = getCurrentUpdatePriority ( ) ;
436- const queuedTarget : QueuedHydrationTarget = {
437- blockedOn : null ,
438- target : target ,
439- priority : updatePriority ,
440- } ;
441- let i = 0 ;
442- for ( ; i < queuedExplicitHydrationTargets . length ; i ++ ) {
443- // Stop once we hit the first target with lower priority than
444- if (
445- ! isHigherEventPriority (
446- updatePriority ,
447- queuedExplicitHydrationTargets [ i ] . priority ,
448- )
449- ) {
450- break ;
451- }
452- }
453- queuedExplicitHydrationTargets . splice ( i , 0 , queuedTarget ) ;
454- if ( i === 0 ) {
455- attemptExplicitHydrationTarget ( queuedTarget ) ;
426+ // TODO: This will read the priority if it's dispatched by the React
427+ // event system but not native events. Should read window.event.type, like
428+ // we do for updates (getCurrentEventPriority).
429+ const updatePriority = getCurrentUpdatePriority ( ) ;
430+ const queuedTarget : QueuedHydrationTarget = {
431+ blockedOn : null ,
432+ target : target ,
433+ priority : updatePriority ,
434+ } ;
435+ let i = 0 ;
436+ for ( ; i < queuedExplicitHydrationTargets . length ; i ++ ) {
437+ // Stop once we hit the first target with lower priority than
438+ if (
439+ ! isHigherEventPriority (
440+ updatePriority ,
441+ queuedExplicitHydrationTargets [ i ] . priority ,
442+ )
443+ ) {
444+ break ;
456445 }
457446 }
447+ queuedExplicitHydrationTargets . splice ( i , 0 , queuedTarget ) ;
448+ if ( i === 0 ) {
449+ attemptExplicitHydrationTarget ( queuedTarget ) ;
450+ }
458451}
459452
460453function attemptReplayContinuousQueuedEvent (
0 commit comments