@@ -14,7 +14,6 @@ import type {EventSystemFlags} from './EventSystemFlags';
1414import type { FiberRoot } from 'react-reconciler/src/ReactInternalTypes' ;
1515import type { EventPriority } from 'react-reconciler/src/ReactEventPriorities' ;
1616
17- import { enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay } from 'shared/ReactFeatureFlags' ;
1817import {
1918 unstable_scheduleCallback as scheduleCallback ,
2019 unstable_NormalPriority as NormalPriority ,
@@ -24,12 +23,8 @@ import {
2423 getContainerFromFiber ,
2524 getSuspenseInstanceFromFiber ,
2625} from 'react-reconciler/src/ReactFiberTreeReflection' ;
27- import {
28- findInstanceBlockingEvent ,
29- return_targetInst ,
30- } from './ReactDOMEventListener' ;
26+ import { findInstanceBlockingEvent } from './ReactDOMEventListener' ;
3127import { setReplayingEvent , resetReplayingEvent } from './CurrentReplayingEvent' ;
32- import { dispatchEventForPluginEventSystem } from './DOMPluginEventSystem' ;
3328import {
3429 getInstanceFromNode ,
3530 getClosestInstanceFromNode ,
@@ -39,8 +34,6 @@ import {isHigherEventPriority} from 'react-reconciler/src/ReactEventPriorities';
3934import { isRootDehydrated } from 'react-reconciler/src/ReactFiberShellHydration' ;
4035
4136import {
42- attemptSynchronousHydration ,
43- attemptDiscreteHydration ,
4437 attemptContinuousHydration ,
4538 attemptHydrationAtCurrentPriority ,
4639} from 'react-reconciler/src/ReactFiberReconciler' ;
@@ -150,48 +143,6 @@ function createQueuedReplayableEvent(
150143 } ;
151144}
152145
153- export function queueDiscreteEvent(
154- blockedOn: null | Container | SuspenseInstance,
155- domEventName: DOMEventName,
156- eventSystemFlags: EventSystemFlags,
157- targetContainer: EventTarget,
158- nativeEvent: AnyNativeEvent,
159- ): void {
160- if ( enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay ) {
161- return ;
162- }
163- const queuedEvent = createQueuedReplayableEvent(
164- blockedOn,
165- domEventName,
166- eventSystemFlags,
167- targetContainer,
168- nativeEvent,
169- );
170- queuedDiscreteEvents.push(queuedEvent);
171- if (queuedDiscreteEvents.length === 1) {
172- // If this was the first discrete event, we might be able to
173- // synchronously unblock it so that preventDefault still works.
174- while ( queuedEvent . blockedOn !== null ) {
175- const fiber = getInstanceFromNode ( queuedEvent . blockedOn ) ;
176- if ( fiber === null ) {
177- break;
178- }
179- attemptSynchronousHydration ( fiber ) ;
180- if ( queuedEvent . blockedOn === null ) {
181- // We got unblocked by hydration. Let's try again.
182- replayUnblockedEvents ( ) ;
183- // If we're reblocked, on an inner boundary, we might need
184- // to attempt hydrating that one.
185- continue ;
186- } else {
187- // We're still blocked from hydration, we have to give up
188- // and replay later.
189- break ;
190- }
191- }
192- }
193- }
194-
195146// Resets the replaying for this type of continuous event to no event.
196147export function clearIfContinuousEvent(
197148 domEventName: DOMEventName,
@@ -433,26 +384,14 @@ function attemptReplayContinuousQueuedEvent(
433384 queuedEvent . nativeEvent ,
434385 ) ;
435386 if ( nextBlockedOn === null ) {
436- if ( enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay ) {
437- const nativeEvent = queuedEvent . nativeEvent ;
438- const nativeEventClone = new nativeEvent . constructor (
439- nativeEvent . type ,
440- ( nativeEvent : any ) ,
441- ) ;
442- setReplayingEvent ( nativeEventClone ) ;
443- nativeEvent . target . dispatchEvent ( nativeEventClone ) ;
444- resetReplayingEvent ( ) ;
445- } else {
446- setReplayingEvent ( queuedEvent . nativeEvent ) ;
447- dispatchEventForPluginEventSystem (
448- queuedEvent . domEventName ,
449- queuedEvent . eventSystemFlags ,
450- queuedEvent . nativeEvent ,
451- return_targetInst ,
452- targetContainer ,
453- ) ;
454- resetReplayingEvent ( ) ;
455- }
387+ const nativeEvent = queuedEvent . nativeEvent ;
388+ const nativeEventClone = new nativeEvent . constructor (
389+ nativeEvent . type ,
390+ ( nativeEvent : any ) ,
391+ ) ;
392+ setReplayingEvent ( nativeEventClone ) ;
393+ nativeEvent . target . dispatchEvent ( nativeEventClone ) ;
394+ resetReplayingEvent ( ) ;
456395 } else {
457396 // We're still blocked. Try again later.
458397 const fiber = getInstanceFromNode ( nextBlockedOn ) ;
@@ -480,56 +419,7 @@ function attemptReplayContinuousQueuedEventInMap(
480419
481420function replayUnblockedEvents ( ) {
482421 hasScheduledReplayAttempt = false ;
483- if ( ! enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay ) {
484- // First replay discrete events.
485- while ( queuedDiscreteEvents . length > 0 ) {
486- const nextDiscreteEvent = queuedDiscreteEvents [ 0 ] ;
487- if ( nextDiscreteEvent . blockedOn !== null ) {
488- // We're still blocked.
489- // Increase the priority of this boundary to unblock
490- // the next discrete event.
491- const fiber = getInstanceFromNode ( nextDiscreteEvent . blockedOn ) ;
492- if ( fiber !== null ) {
493- attemptDiscreteHydration ( fiber ) ;
494- }
495- break ;
496- }
497- const targetContainers = nextDiscreteEvent . targetContainers ;
498- while ( targetContainers . length > 0 ) {
499- const targetContainer = targetContainers [ 0 ] ;
500- const nextBlockedOn = findInstanceBlockingEvent (
501- nextDiscreteEvent . domEventName ,
502- nextDiscreteEvent . eventSystemFlags ,
503- targetContainer ,
504- nextDiscreteEvent . nativeEvent ,
505- ) ;
506- if ( nextBlockedOn === null ) {
507- // This whole function is in !enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
508- // so we don't need the new replay behavior code branch.
509- setReplayingEvent ( nextDiscreteEvent . nativeEvent ) ;
510- dispatchEventForPluginEventSystem (
511- nextDiscreteEvent . domEventName ,
512- nextDiscreteEvent . eventSystemFlags ,
513- nextDiscreteEvent . nativeEvent ,
514- return_targetInst ,
515- targetContainer ,
516- ) ;
517- resetReplayingEvent ( ) ;
518- } else {
519- // We're still blocked. Try again later.
520- nextDiscreteEvent . blockedOn = nextBlockedOn ;
521- break ;
522- }
523- // This target container was successfully dispatched. Try the next.
524- targetContainers . shift ( ) ;
525- }
526- if ( nextDiscreteEvent . blockedOn === null ) {
527- // We've successfully replayed the first event. Let's try the next one.
528- queuedDiscreteEvents . shift ( ) ;
529- }
530- }
531- }
532- // Next replay any continuous events.
422+ // Replay any continuous events.
533423 if ( queuedFocus !== null && attemptReplayContinuousQueuedEvent ( queuedFocus ) ) {
534424 queuedFocus = null ;
535425 }
0 commit comments