@@ -14,7 +14,6 @@ import type {EventSystemFlags} from './EventSystemFlags';
14
14
import type { FiberRoot } from 'react-reconciler/src/ReactInternalTypes' ;
15
15
import type { EventPriority } from 'react-reconciler/src/ReactEventPriorities' ;
16
16
17
- import { enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay } from 'shared/ReactFeatureFlags' ;
18
17
import {
19
18
unstable_scheduleCallback as scheduleCallback ,
20
19
unstable_NormalPriority as NormalPriority ,
@@ -24,12 +23,8 @@ import {
24
23
getContainerFromFiber ,
25
24
getSuspenseInstanceFromFiber ,
26
25
} from 'react-reconciler/src/ReactFiberTreeReflection' ;
27
- import {
28
- findInstanceBlockingEvent ,
29
- return_targetInst ,
30
- } from './ReactDOMEventListener' ;
26
+ import { findInstanceBlockingEvent } from './ReactDOMEventListener' ;
31
27
import { setReplayingEvent , resetReplayingEvent } from './CurrentReplayingEvent' ;
32
- import { dispatchEventForPluginEventSystem } from './DOMPluginEventSystem' ;
33
28
import {
34
29
getInstanceFromNode ,
35
30
getClosestInstanceFromNode ,
@@ -39,8 +34,6 @@ import {isHigherEventPriority} from 'react-reconciler/src/ReactEventPriorities';
39
34
import { isRootDehydrated } from 'react-reconciler/src/ReactFiberShellHydration' ;
40
35
41
36
import {
42
- attemptSynchronousHydration ,
43
- attemptDiscreteHydration ,
44
37
attemptContinuousHydration ,
45
38
attemptHydrationAtCurrentPriority ,
46
39
} from 'react-reconciler/src/ReactFiberReconciler' ;
@@ -150,48 +143,6 @@ function createQueuedReplayableEvent(
150
143
} ;
151
144
}
152
145
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
-
195
146
// Resets the replaying for this type of continuous event to no event.
196
147
export function clearIfContinuousEvent(
197
148
domEventName: DOMEventName,
@@ -433,26 +384,14 @@ function attemptReplayContinuousQueuedEvent(
433
384
queuedEvent . nativeEvent ,
434
385
) ;
435
386
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 ( ) ;
456
395
} else {
457
396
// We're still blocked. Try again later.
458
397
const fiber = getInstanceFromNode ( nextBlockedOn ) ;
@@ -480,56 +419,7 @@ function attemptReplayContinuousQueuedEventInMap(
480
419
481
420
function replayUnblockedEvents ( ) {
482
421
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.
533
423
if ( queuedFocus !== null && attemptReplayContinuousQueuedEvent ( queuedFocus ) ) {
534
424
queuedFocus = null ;
535
425
}
0 commit comments