Skip to content

Commit 3d10eca

Browse files
authored
Move scheduler priority check into ReactDOM (#20778)
* Move scheduler priority check into ReactDOM * TODO
1 parent ad8211d commit 3d10eca

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

packages/react-dom/src/events/DOMEventNames.js

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export type DOMEventName =
6262
| 'loadeddata'
6363
| 'loadedmetadata'
6464
| 'lostpointercapture'
65+
| 'message'
6566
| 'mousedown'
6667
| 'mouseenter'
6768
| 'mouseleave'

packages/react-dom/src/events/ReactDOMEventListener.js

+19
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,18 @@ import {
5555
DefaultLanePriority as DefaultLanePriority_old,
5656
getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_old,
5757
setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_old,
58+
schedulerPriorityToLanePriority as schedulerPriorityToLanePriority_old,
5859
} from 'react-reconciler/src/ReactFiberLane.old';
5960
import {
6061
InputDiscreteLanePriority as InputDiscreteLanePriority_new,
6162
InputContinuousLanePriority as InputContinuousLanePriority_new,
6263
DefaultLanePriority as DefaultLanePriority_new,
6364
getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_new,
6465
setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_new,
66+
schedulerPriorityToLanePriority as schedulerPriorityToLanePriority_new,
6567
} from 'react-reconciler/src/ReactFiberLane.new';
68+
import {getCurrentPriorityLevel as getCurrentPriorityLevel_old} from 'react-reconciler/src/SchedulerWithReactIntegration.old';
69+
import {getCurrentPriorityLevel as getCurrentPriorityLevel_new} from 'react-reconciler/src/SchedulerWithReactIntegration.new';
6670

6771
const InputDiscreteLanePriority = enableNewReconciler
6872
? InputDiscreteLanePriority_new
@@ -79,6 +83,12 @@ const getCurrentUpdateLanePriority = enableNewReconciler
7983
const setCurrentUpdateLanePriority = enableNewReconciler
8084
? setCurrentUpdateLanePriority_new
8185
: setCurrentUpdateLanePriority_old;
86+
const schedulerPriorityToLanePriority = enableNewReconciler
87+
? schedulerPriorityToLanePriority_new
88+
: schedulerPriorityToLanePriority_old;
89+
const getCurrentPriorityLevel = enableNewReconciler
90+
? getCurrentPriorityLevel_new
91+
: getCurrentPriorityLevel_old;
8292

8393
const {
8494
unstable_UserBlockingPriority: UserBlockingPriority,
@@ -428,6 +438,15 @@ export function getEventPriority(domEventName: DOMEventName): * {
428438
case 'mouseenter':
429439
case 'mouseleave':
430440
return InputContinuousLanePriority;
441+
case 'message': {
442+
// We might be in the Scheduler callback.
443+
// Eventually this mechanism will be replaced by a check
444+
// of the current priority on the native scheduler.
445+
const schedulerPriority = getCurrentPriorityLevel();
446+
// TODO: Inline schedulerPriorityToLanePriority into this file
447+
// when we delete the enableNativeEventPriorityInference flag.
448+
return schedulerPriorityToLanePriority(schedulerPriority);
449+
}
431450
default:
432451
return DefaultLanePriority;
433452
}

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,7 @@ export function requestUpdateLane(fiber: Fiber): Lane {
465465
} else {
466466
if (enableNativeEventPriorityInference) {
467467
const eventLanePriority = getCurrentEventPriority();
468-
if (eventLanePriority === DefaultLanePriority) {
469-
// TODO: move this case into the ReactDOM host config.
470-
const schedulerLanePriority = schedulerPriorityToLanePriority(
471-
schedulerPriority,
472-
);
473-
lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes);
474-
} else {
475-
lane = findUpdateLane(eventLanePriority, currentEventWipLanes);
476-
}
468+
lane = findUpdateLane(eventLanePriority, currentEventWipLanes);
477469
} else {
478470
const schedulerLanePriority = schedulerPriorityToLanePriority(
479471
schedulerPriority,

0 commit comments

Comments
 (0)