@@ -11,7 +11,6 @@ import type {AnyNativeEvent} from '../events/PluginModuleType'; |
11 | 11 | import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes'; |
12 | 12 | import type {Container, SuspenseInstance} from '../client/ReactDOMHostConfig'; |
13 | 13 | import type {DOMEventName} from '../events/DOMEventNames'; |
14 | | -import type {EventPriority} from 'shared/ReactTypes'; |
15 | 14 |
|
16 | 15 | // Intentionally not named imports because Rollup would use dynamic dispatch for |
17 | 16 | // CommonJS interop named imports. |
@@ -44,27 +43,36 @@ import { |
44 | 43 | decoupleUpdatePriorityFromScheduler, |
45 | 44 | enableNewReconciler, |
46 | 45 | } from 'shared/ReactFeatureFlags'; |
47 | | -import {ContinuousEvent, DefaultEvent, DiscreteEvent} from 'shared/ReactTypes'; |
48 | 46 | import {dispatchEventForPluginEventSystem} from './DOMPluginEventSystem'; |
49 | 47 | import { |
50 | 48 | flushDiscreteUpdatesIfNeeded, |
51 | 49 | discreteUpdates, |
52 | 50 | } from './ReactDOMUpdateBatching'; |
53 | 51 |
|
54 | 52 | import { |
| 53 | + InputDiscreteLanePriority as InputDiscreteLanePriority_old, |
55 | 54 | InputContinuousLanePriority as InputContinuousLanePriority_old, |
| 55 | + DefaultLanePriority as DefaultLanePriority_old, |
56 | 56 | getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_old, |
57 | 57 | setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_old, |
58 | 58 | } from 'react-reconciler/src/ReactFiberLane.old'; |
59 | 59 | import { |
| 60 | + InputDiscreteLanePriority as InputDiscreteLanePriority_new, |
60 | 61 | InputContinuousLanePriority as InputContinuousLanePriority_new, |
| 62 | + DefaultLanePriority as DefaultLanePriority_new, |
61 | 63 | getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_new, |
62 | 64 | setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_new, |
63 | 65 | } from 'react-reconciler/src/ReactFiberLane.new'; |
64 | 66 |
|
| 67 | +const InputDiscreteLanePriority = enableNewReconciler |
| 68 | + ? InputDiscreteLanePriority_new |
| 69 | + : InputDiscreteLanePriority_old; |
65 | 70 | const InputContinuousLanePriority = enableNewReconciler |
66 | 71 | ? InputContinuousLanePriority_new |
67 | 72 | : InputContinuousLanePriority_old; |
| 73 | +const DefaultLanePriority = enableNewReconciler |
| 74 | + ? DefaultLanePriority_new |
| 75 | + : DefaultLanePriority_old; |
68 | 76 | const getCurrentUpdateLanePriority = enableNewReconciler |
69 | 77 | ? getCurrentUpdateLanePriority_new |
70 | 78 | : getCurrentUpdateLanePriority_old; |
@@ -108,16 +116,16 @@ export function createEventListenerWrapperWithPriority( |
108 | 116 | domEventName: DOMEventName, |
109 | 117 | eventSystemFlags: EventSystemFlags, |
110 | 118 | ): Function { |
111 | | - const eventPriority = getEventPriorityForPluginSystem(domEventName); |
| 119 | + const eventPriority = getEventPriority(domEventName); |
112 | 120 | let listenerWrapper; |
113 | 121 | switch (eventPriority) { |
114 | | - case DiscreteEvent: |
| 122 | + case InputDiscreteLanePriority: |
115 | 123 | listenerWrapper = dispatchDiscreteEvent; |
116 | 124 | break; |
117 | | - case ContinuousEvent: |
| 125 | + case InputContinuousLanePriority: |
118 | 126 | listenerWrapper = dispatchContinuousEvent; |
119 | 127 | break; |
120 | | - case DefaultEvent: |
| 128 | + case DefaultLanePriority: |
121 | 129 | default: |
122 | 130 | listenerWrapper = dispatchEvent; |
123 | 131 | break; |
@@ -340,9 +348,7 @@ export function attemptToDispatchEvent( |
340 | 348 | return null; |
341 | 349 | } |
342 | 350 |
|
343 | | -function getEventPriorityForPluginSystem( |
344 | | - domEventName: DOMEventName, |
345 | | -): EventPriority { |
| 351 | +function getEventPriority(domEventName: DOMEventName) { |
346 | 352 | switch (domEventName) { |
347 | 353 | // Used by SimpleEventPlugin: |
348 | 354 | case 'cancel': |
@@ -391,7 +397,7 @@ function getEventPriorityForPluginSystem( |
391 | 397 | // eslint-disable-next-line no-fallthrough |
392 | 398 | case 'beforeblur': |
393 | 399 | case 'afterblur': |
394 | | - return DiscreteEvent; |
| 400 | + return InputDiscreteLanePriority; |
395 | 401 | case 'drag': |
396 | 402 | case 'dragenter': |
397 | 403 | case 'dragexit': |
@@ -407,8 +413,8 @@ function getEventPriorityForPluginSystem( |
407 | 413 | case 'toggle': |
408 | 414 | case 'touchmove': |
409 | 415 | case 'wheel': |
410 | | - return ContinuousEvent; |
| 416 | + return InputContinuousLanePriority; |
411 | 417 | default: |
412 | | - return DefaultEvent; |
| 418 | + return DefaultLanePriority; |
413 | 419 | } |
414 | 420 | } |