Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move event things around (facebook#19433)
* Put all synthetic events in one file

* Inline other helpers

* Remove Modern from filenames
  • Loading branch information
gaearon committed Jul 22, 2020
1 parent 1aae05c commit 125d1a1
Show file tree
Hide file tree
Showing 29 changed files with 441 additions and 594 deletions.
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMComponent.js
Expand Up @@ -89,7 +89,7 @@ import {
listenToReactEvent,
mediaEventTypes,
listenToNonDelegatedEvent,
} from '../events/DOMModernPluginEventSystem';
} from '../events/DOMPluginEventSystem';
import {getEventListenerMap} from './ReactDOMComponentTree';
import {
TOP_LOAD,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMEventHandle.js
Expand Up @@ -25,7 +25,7 @@ import {ELEMENT_NODE, COMMENT_NODE} from '../shared/HTMLNodeType';
import {
listenToNativeEvent,
addEventTypeToDispatchConfig,
} from '../events/DOMModernPluginEventSystem';
} from '../events/DOMPluginEventSystem';

import {HostRoot, HostPortal} from 'react-reconciler/src/ReactWorkTags';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMHostConfig.js
Expand Up @@ -80,7 +80,7 @@ import {
} from 'shared/ReactFeatureFlags';
import {HostComponent, HostText} from 'react-reconciler/src/ReactWorkTags';
import {TOP_BEFORE_BLUR, TOP_AFTER_BLUR} from '../events/DOMTopLevelEventTypes';
import {listenToReactEvent} from '../events/DOMModernPluginEventSystem';
import {listenToReactEvent} from '../events/DOMPluginEventSystem';

export type Type = string;
export type Props = {
Expand Down
Expand Up @@ -99,11 +99,11 @@ import {
} from './EventListener';
import {removeTrappedEventListener} from './DeprecatedDOMEventResponderSystem';
import {topLevelEventsToReactNames} from './DOMEventProperties';
import * as ModernBeforeInputEventPlugin from './plugins/ModernBeforeInputEventPlugin';
import * as ModernChangeEventPlugin from './plugins/ModernChangeEventPlugin';
import * as ModernEnterLeaveEventPlugin from './plugins/ModernEnterLeaveEventPlugin';
import * as ModernSelectEventPlugin from './plugins/ModernSelectEventPlugin';
import * as ModernSimpleEventPlugin from './plugins/ModernSimpleEventPlugin';
import * as BeforeInputEventPlugin from './plugins/BeforeInputEventPlugin';
import * as ChangeEventPlugin from './plugins/ChangeEventPlugin';
import * as EnterLeaveEventPlugin from './plugins/EnterLeaveEventPlugin';
import * as SelectEventPlugin from './plugins/SelectEventPlugin';
import * as SimpleEventPlugin from './plugins/SimpleEventPlugin';

type DispatchListener = {|
instance: null | Fiber,
Expand All @@ -119,11 +119,11 @@ type DispatchEntry = {|
export type DispatchQueue = Array<DispatchEntry>;

// TODO: remove top-level side effect.
ModernSimpleEventPlugin.registerEvents();
ModernEnterLeaveEventPlugin.registerEvents();
ModernChangeEventPlugin.registerEvents();
ModernSelectEventPlugin.registerEvents();
ModernBeforeInputEventPlugin.registerEvents();
SimpleEventPlugin.registerEvents();
EnterLeaveEventPlugin.registerEvents();
ChangeEventPlugin.registerEvents();
SelectEventPlugin.registerEvents();
BeforeInputEventPlugin.registerEvents();

function extractEvents(
dispatchQueue: DispatchQueue,
Expand All @@ -140,7 +140,7 @@ function extractEvents(
// should probably be inlined somewhere and have its logic
// be core the to event system. This would potentially allow
// us to ship builds of React without the polyfilled plugins below.
ModernSimpleEventPlugin.extractEvents(
SimpleEventPlugin.extractEvents(
dispatchQueue,
topLevelType,
targetInst,
Expand Down Expand Up @@ -169,7 +169,7 @@ function extractEvents(
// that might cause other unknown side-effects that we
// can't forsee right now.
if (shouldProcessPolyfillPlugins) {
ModernEnterLeaveEventPlugin.extractEvents(
EnterLeaveEventPlugin.extractEvents(
dispatchQueue,
topLevelType,
targetInst,
Expand All @@ -178,7 +178,7 @@ function extractEvents(
eventSystemFlags,
targetContainer,
);
ModernChangeEventPlugin.extractEvents(
ChangeEventPlugin.extractEvents(
dispatchQueue,
topLevelType,
targetInst,
Expand All @@ -187,7 +187,7 @@ function extractEvents(
eventSystemFlags,
targetContainer,
);
ModernSelectEventPlugin.extractEvents(
SelectEventPlugin.extractEvents(
dispatchQueue,
topLevelType,
targetInst,
Expand All @@ -196,7 +196,7 @@ function extractEvents(
eventSystemFlags,
targetContainer,
);
ModernBeforeInputEventPlugin.extractEvents(
BeforeInputEventPlugin.extractEvents(
dispatchQueue,
topLevelType,
targetInst,
Expand Down Expand Up @@ -297,7 +297,7 @@ export function processDispatchQueue(
for (let i = 0; i < dispatchQueue.length; i++) {
const {event, listeners} = dispatchQueue[i];
processDispatchQueueItemsInOrder(event, listeners, inCapturePhase);
// Modern event system doesn't use pooling.
// event system doesn't use pooling.
}
// This would be a good time to rethrow if any of the event handlers threw.
rethrowCaughtError();
Expand Down Expand Up @@ -816,9 +816,9 @@ export function accumulateSinglePhaseListeners(
}

// We should only use this function for:
// - ModernBeforeInputEventPlugin
// - ModernChangeEventPlugin
// - ModernSelectEventPlugin
// - BeforeInputEventPlugin
// - ChangeEventPlugin
// - SelectEventPlugin
// This is because we only process these plugins
// in the bubble phase, so we need to accumulate two
// phase event listeners (via emulation).
Expand Down Expand Up @@ -969,7 +969,7 @@ function accumulateEnterLeaveListenersForEvent(
}

// We should only use this function for:
// - ModernEnterLeaveEventPlugin
// - EnterLeaveEventPlugin
// This is because we only process this plugin
// in the bubble phase, so we need to accumulate two
// phase event listeners.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/ReactDOMEventListener.js
Expand Up @@ -51,7 +51,7 @@ import {
DiscreteEvent,
} from 'shared/ReactTypes';
import {getEventPriorityForPluginSystem} from './DOMEventProperties';
import {dispatchEventForPluginEventSystem} from './DOMModernPluginEventSystem';
import {dispatchEventForPluginEventSystem} from './DOMPluginEventSystem';
import {
flushDiscreteUpdatesIfNeeded,
discreteUpdates,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/ReactDOMEventReplaying.js
Expand Up @@ -128,7 +128,7 @@ import {
TOP_FOCUS_OUT,
} from './DOMTopLevelEventTypes';
import {IS_REPLAYED} from './EventSystemFlags';
import {listenToNativeEvent} from './DOMModernPluginEventSystem';
import {listenToNativeEvent} from './DOMPluginEventSystem';
import {addResponderEventSystemEvent} from './DeprecatedDOMEventResponderSystem';

type QueuedReplayableEvent = {|
Expand Down
21 changes: 0 additions & 21 deletions packages/react-dom/src/events/SyntheticAnimationEvent.js

This file was deleted.

22 changes: 0 additions & 22 deletions packages/react-dom/src/events/SyntheticClipboardEvent.js

This file was deleted.

18 changes: 0 additions & 18 deletions packages/react-dom/src/events/SyntheticCompositionEvent.js

This file was deleted.

18 changes: 0 additions & 18 deletions packages/react-dom/src/events/SyntheticDragEvent.js

This file was deleted.

0 comments on commit 125d1a1

Please sign in to comment.