-
Notifications
You must be signed in to change notification settings - Fork 47.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decouple event priority list from event name list #20760
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import type {AnyNativeEvent} from '../events/PluginModuleType'; | |
import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes'; | ||
import type {Container, SuspenseInstance} from '../client/ReactDOMHostConfig'; | ||
import type {DOMEventName} from '../events/DOMEventNames'; | ||
import type {EventPriority} from 'shared/ReactTypes'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're going to replace this with lane priority later. Conveniently, this file already imports them. |
||
|
||
// Intentionally not named imports because Rollup would use dynamic dispatch for | ||
// CommonJS interop named imports. | ||
|
@@ -44,7 +45,6 @@ import { | |
enableNewReconciler, | ||
} from 'shared/ReactFeatureFlags'; | ||
import {ContinuousEvent, DefaultEvent, DiscreteEvent} from 'shared/ReactTypes'; | ||
import {getEventPriorityForPluginSystem} from './DOMEventProperties'; | ||
import {dispatchEventForPluginEventSystem} from './DOMPluginEventSystem'; | ||
import { | ||
flushDiscreteUpdatesIfNeeded, | ||
|
@@ -339,3 +339,76 @@ export function attemptToDispatchEvent( | |
// We're not blocked on anything. | ||
return null; | ||
} | ||
|
||
function getEventPriorityForPluginSystem( | ||
domEventName: DOMEventName, | ||
): EventPriority { | ||
switch (domEventName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copypasta from the list except that it doesn't need Default ones. Because they're ... default. |
||
// Used by SimpleEventPlugin: | ||
case 'cancel': | ||
case 'click': | ||
case 'close': | ||
case 'contextmenu': | ||
case 'copy': | ||
case 'cut': | ||
case 'auxclick': | ||
case 'dblclick': | ||
case 'dragend': | ||
case 'dragstart': | ||
case 'drop': | ||
case 'focusin': | ||
case 'focusout': | ||
case 'input': | ||
case 'invalid': | ||
case 'keydown': | ||
case 'keypress': | ||
case 'keyup': | ||
case 'mousedown': | ||
case 'mouseup': | ||
case 'paste': | ||
case 'pause': | ||
case 'play': | ||
case 'pointercancel': | ||
case 'pointerdown': | ||
case 'pointerup': | ||
case 'ratechange': | ||
case 'reset': | ||
case 'seeked': | ||
case 'submit': | ||
case 'touchcancel': | ||
case 'touchend': | ||
case 'touchstart': | ||
case 'volumechange': | ||
// Used by polyfills: | ||
// eslint-disable-next-line no-fallthrough | ||
case 'change': | ||
case 'selectionchange': | ||
case 'textInput': | ||
case 'compositionstart': | ||
case 'compositionend': | ||
case 'compositionupdate': | ||
// Only enableCreateEventHandleAPI: | ||
// eslint-disable-next-line no-fallthrough | ||
case 'beforeblur': | ||
case 'afterblur': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically these don't exist outside experimental but no real harm mentioning them. |
||
return DiscreteEvent; | ||
case 'drag': | ||
case 'dragenter': | ||
case 'dragexit': | ||
case 'dragleave': | ||
case 'dragover': | ||
case 'mousemove': | ||
case 'mouseout': | ||
case 'mouseover': | ||
case 'pointermove': | ||
case 'pointerout': | ||
case 'pointerover': | ||
case 'scroll': | ||
case 'toggle': | ||
case 'touchmove': | ||
case 'wheel': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😍 |
||
return ContinuousEvent; | ||
default: | ||
return DefaultEvent; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These go away from this file because they're not SimpleEventPlugin events. They were only listed here to give them a discrete priority, which we do in the new switch.