Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
Don't declare block variables inside loops
  • Loading branch information
gaearon committed Sep 25, 2020
1 parent 697d3c4 commit f82ea53
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/react-dom/src/events/DOMPluginEventSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,24 +733,30 @@ export function accumulateSinglePhaseListeners(

let instance = targetFiber;
let lastHostComponent = null;
let lastCurrentTarget = null;
const targetType = event.nativeEvent.type;

// Accumulate all instances and listeners via the target -> root path.
while (instance !== null) {
const {stateNode, tag} = instance;
// Handle listeners that are on HostComponents (i.e. <div>)
if (tag === HostComponent && stateNode !== null) {
const currentTarget = stateNode;
lastHostComponent = currentTarget;
lastHostComponent = stateNode;

// createEventHandle listeners
if (enableCreateEventHandleAPI) {
const eventHandlerListeners = getEventHandlerListeners(currentTarget);
const eventHandlerListeners = getEventHandlerListeners(
lastHostComponent,
);
if (eventHandlerListeners !== null) {
eventHandlerListeners.forEach(entry => {
if (entry.type === targetType && entry.capture === inCapturePhase) {
listeners.push(
createDispatchListener(instance, entry.callback, currentTarget),
createDispatchListener(
instance,
entry.callback,
lastHostComponent,
),
);
}
});
Expand All @@ -762,7 +768,7 @@ export function accumulateSinglePhaseListeners(
const listener = getListener(instance, reactEventName);
if (listener != null) {
listeners.push(
createDispatchListener(instance, listener, currentTarget),
createDispatchListener(instance, listener, lastHostComponent),
);
}
}
Expand All @@ -778,15 +784,14 @@ export function accumulateSinglePhaseListeners(
const eventHandlerListeners = getEventHandlerListeners(
reactScopeInstance,
);
const lastCurrentTarget = ((lastHostComponent: any): Element);
if (eventHandlerListeners !== null) {
eventHandlerListeners.forEach(entry => {
if (entry.type === targetType && entry.capture === inCapturePhase) {
listeners.push(
createDispatchListener(
instance,
entry.callback,
lastCurrentTarget,
lastHostComponent,
),
);
}
Expand Down

0 comments on commit f82ea53

Please sign in to comment.