Skip to content

Commit

Permalink
Remove unnecessary field
Browse files Browse the repository at this point in the history
It is unnecessary because it's only true when retval is null.
  • Loading branch information
gaearon committed Dec 2, 2021
1 parent 6bcc386 commit 905ab99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
16 changes: 5 additions & 11 deletions packages/react-dom/src/events/ReactDOMEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,14 @@ export function dispatchEvent(
targetContainer,
nativeEvent,
);
if (return_shouldDispatch) {
if (blockedOn === null) {
dispatchEventForPluginEventSystem(
domEventName,
eventSystemFlags,
nativeEvent,
return_targetInst,
targetContainer,
);
}
if (blockedOn === null) {
// We successfully dispatched this event.
if (allowReplay) {
clearIfContinuousEvent(domEventName, nativeEvent);
}
Expand Down Expand Up @@ -250,7 +247,7 @@ export function dispatchEvent(
targetContainer,
nativeEvent,
);
if (return_shouldDispatch) {
if (nextBlockedOn === null) {
dispatchEventForPluginEventSystem(
domEventName,
eventSystemFlags,
Expand Down Expand Up @@ -281,22 +278,20 @@ export function dispatchEvent(
);
}

export let return_shouldDispatch = false;
export let return_targetInst = null;

// Returns a SuspenseInstance or Container if it's blocked.
// The two fields above are conceptually part of the return value.
// The return_targetInst field above is conceptually part of the return value.
export function findInstanceBlockingEvent(
domEventName: DOMEventName,
eventSystemFlags: EventSystemFlags,
targetContainer: EventTarget,
nativeEvent: AnyNativeEvent,
): null | Container | SuspenseInstance {
return_shouldDispatch = false;
return_targetInst = null;

// TODO: Warn if _enabled is false.

return_targetInst = null;

const nativeEventTarget = getEventTarget(nativeEvent);
let targetInst = getClosestInstanceFromNode(nativeEventTarget);

Expand Down Expand Up @@ -338,7 +333,6 @@ export function findInstanceBlockingEvent(
}
}
return_targetInst = targetInst;
return_shouldDispatch = true;
// We're not blocked on anything.
return null;
}
Expand Down
11 changes: 4 additions & 7 deletions packages/react-dom/src/events/ReactDOMEventReplaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
import {
findInstanceBlockingEvent,
return_targetInst,
return_shouldDispatch,
} from './ReactDOMEventListener';
import {dispatchEventForPluginEventSystem} from './DOMPluginEventSystem';
import {
Expand Down Expand Up @@ -473,16 +472,15 @@ function attemptReplayContinuousQueuedEvent(
targetContainer,
queuedEvent.nativeEvent,
);
if (return_shouldDispatch) {
if (nextBlockedOn === null) {
dispatchEventForPluginEventSystem(
queuedEvent.domEventName,
queuedEvent.eventSystemFlags,
queuedEvent.nativeEvent,
return_targetInst,
targetContainer,
);
}
if (nextBlockedOn !== null) {
} else {
// We're still blocked. Try again later.
const fiber = getInstanceFromNode(nextBlockedOn);
if (fiber !== null) {
Expand Down Expand Up @@ -532,16 +530,15 @@ function replayUnblockedEvents() {
targetContainer,
nextDiscreteEvent.nativeEvent,
);
if (return_shouldDispatch) {
if (nextBlockedOn === null) {
dispatchEventForPluginEventSystem(
nextDiscreteEvent.domEventName,
nextDiscreteEvent.eventSystemFlags,
nextDiscreteEvent.nativeEvent,
return_targetInst,
targetContainer,
);
}
if (nextBlockedOn !== null) {
} else {
// We're still blocked. Try again later.
nextDiscreteEvent.blockedOn = nextBlockedOn;
break;
Expand Down

0 comments on commit 905ab99

Please sign in to comment.