Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EventPluginRegistry.getPluginModuleForEvent #9110

Merged
merged 1 commit into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,6 @@ src/renderers/shared/shared/event/__tests__/EventPluginRegistry-test.js
* should publish registration names of injected plugins
* should throw if multiple registration names collide
* should throw if an invalid event is published
* should be able to get the plugin from synthetic events

src/renderers/shared/shared/event/eventPlugins/__tests__/ResponderEventPlugin-test.js
* should do nothing when no one wants to respond
Expand Down
36 changes: 0 additions & 36 deletions src/renderers/shared/shared/event/EventPluginRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import type {
DispatchConfig,
ReactSyntheticEvent,
} from 'ReactSyntheticEventType';

import type {
Expand Down Expand Up @@ -257,41 +256,6 @@ var EventPluginRegistry = {
}
},

/**
* Looks up the plugin for the supplied event.
*
* @param {object} event A synthetic event.
* @return {?object} The plugin that created the supplied event.
* @internal
*/
getPluginModuleForEvent: function(
event: ReactSyntheticEvent,
): null | PluginModule<AnyNativeEvent> {
var dispatchConfig = event.dispatchConfig;
if (dispatchConfig.registrationName) {
return EventPluginRegistry.registrationNameModules[
dispatchConfig.registrationName
] || null;
}
if (dispatchConfig.phasedRegistrationNames !== undefined) {
// pulling phasedRegistrationNames out of dispatchConfig helps Flow see
// that it is not undefined.
var {phasedRegistrationNames} = dispatchConfig;
for (var phase in phasedRegistrationNames) {
if (!phasedRegistrationNames.hasOwnProperty(phase)) {
continue;
}
var pluginModule = EventPluginRegistry.registrationNameModules[
phasedRegistrationNames[phase]
];
if (pluginModule) {
return pluginModule;
}
}
}
return null;
},

/**
* Exposed for unit testing.
* @private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,40 +225,4 @@ describe('EventPluginRegistry', () => {
'`one`.'
);
});

it('should be able to get the plugin from synthetic events', () => {
var clickDispatchConfig = {
registrationName: 'onClick',
};
var magicDispatchConfig = {
phasedRegistrationNames: {
bubbled: 'onMagicBubble',
captured: 'onMagicCapture',
},
};

var OnePlugin = createPlugin({
eventTypes: {
click: clickDispatchConfig,
magic: magicDispatchConfig,
},
});

var clickEvent = {dispatchConfig: clickDispatchConfig};
var magicEvent = {dispatchConfig: magicDispatchConfig};

expect(EventPluginRegistry.getPluginModuleForEvent(clickEvent)).toBe(null);
expect(EventPluginRegistry.getPluginModuleForEvent(magicEvent)).toBe(null);

EventPluginRegistry.injectEventPluginsByName({one: OnePlugin});
EventPluginRegistry.injectEventPluginOrder(['one']);

expect(
EventPluginRegistry.getPluginModuleForEvent(clickEvent)
).toBe(OnePlugin);
expect(
EventPluginRegistry.getPluginModuleForEvent(magicEvent)
).toBe(OnePlugin);
});

});