Skip to content

Commit

Permalink
Fix circular module imports causing file size increase (#15231)
Browse files Browse the repository at this point in the history
* Fix circular module imports causing file size increase
  • Loading branch information
trueadm authored Mar 28, 2019
1 parent 669cafb commit 1cfd256
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/react-dom/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {canUseDOM} from 'shared/ExecutionEnvironment';
import warningWithoutStack from 'shared/warningWithoutStack';
import type {ReactEventResponderEventType} from 'shared/ReactTypes';
import type {DOMTopLevelEventType} from 'events/TopLevelEventTypes';
import {setListenToResponderEventTypes} from '../events/DOMEventResponderSystem';

import {
getValueForAttribute,
Expand Down Expand Up @@ -1337,3 +1338,8 @@ export function listenToEventResponderEventTypes(
}
}
}

// We can remove this once the event API is stable and out of a flag
if (enableEventAPI) {
setListenToResponderEventTypes(listenToEventResponderEventTypes);
}
11 changes: 9 additions & 2 deletions packages/react-dom/src/events/DOMEventResponderSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ import {interactiveUpdates} from 'events/ReactGenericBatching';
import {executeDispatch} from 'events/EventPluginUtils';
import type {Fiber} from 'react-reconciler/src/ReactFiber';

import {listenToEventResponderEventTypes} from '../client/ReactDOMComponent';
import {getClosestInstanceFromNode} from '../client/ReactDOMComponentTree';

import {enableEventAPI} from 'shared/ReactFeatureFlags';

let listenToResponderEventTypesImpl;

export function setListenToResponderEventTypes(
_listenToResponderEventTypesImpl: Function,
) {
listenToResponderEventTypesImpl = _listenToResponderEventTypesImpl;
}

const rootEventTypesToEventComponents: Map<
DOMTopLevelEventType | string,
Set<Fiber>,
Expand Down Expand Up @@ -156,7 +163,7 @@ DOMEventResponderContext.prototype.addRootEventTypes = function(
rootEventTypes: Array<ReactEventResponderEventType>,
) {
const element = this.eventTarget.ownerDocument;
listenToEventResponderEventTypes(rootEventTypes, element);
listenToResponderEventTypesImpl(rootEventTypes, element);
const eventComponent = this._fiber;
for (let i = 0; i < rootEventTypes.length; i++) {
const rootEventType = rootEventTypes[i];
Expand Down

0 comments on commit 1cfd256

Please sign in to comment.