Skip to content

Commit

Permalink
Kill keyOf :) (#7615)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeux authored Aug 30, 2016
1 parent 2f9a9dc commit f7076b7
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 201 deletions.
3 changes: 1 addition & 2 deletions src/addons/link/LinkedStateMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ var LinkedStateMixin = {
* ReactLink will have the current value of this.state[key] and will call
* setState() when a change is requested.
*
* @param {string} key state key to update. Note: you may want to use keyOf()
* if you're using Google Closure Compiler advanced mode.
* @param {string} key state key to update.
* @return {ReactLink} ReactLink instance linking to the state.
*/
linkState: function(key) {
Expand Down
13 changes: 6 additions & 7 deletions src/addons/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

'use strict';

var keyOf = require('keyOf');
var invariant = require('invariant');
var hasOwnProperty = {}.hasOwnProperty;

Expand All @@ -27,12 +26,12 @@ function shallowCopy(x) {
}
}

var COMMAND_PUSH = keyOf({$push: null});
var COMMAND_UNSHIFT = keyOf({$unshift: null});
var COMMAND_SPLICE = keyOf({$splice: null});
var COMMAND_SET = keyOf({$set: null});
var COMMAND_MERGE = keyOf({$merge: null});
var COMMAND_APPLY = keyOf({$apply: null});
var COMMAND_PUSH = '$push';
var COMMAND_UNSHIFT = '$unshift';
var COMMAND_SPLICE = '$splice';
var COMMAND_SET = '$set';
var COMMAND_MERGE = '$merge';
var COMMAND_APPLY = '$apply';

var ALL_COMMANDS_LIST = [
COMMAND_PUSH,
Expand Down
3 changes: 1 addition & 2 deletions src/isomorphic/classic/class/ReactClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ var ReactNoopUpdateQueue = require('ReactNoopUpdateQueue');

var emptyObject = require('emptyObject');
var invariant = require('invariant');
var keyOf = require('keyOf');
var warning = require('warning');

import type { ReactPropTypeLocations } from 'ReactPropTypeLocations';

var MIXINS_KEY = keyOf({mixins: null});
var MIXINS_KEY = 'mixins';

/**
* Policies that describe methods in `ReactClassInterface`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

var keyOf = require('keyOf');

var EventListener;
var EventPluginHub;
var EventPluginRegistry;
Expand All @@ -36,10 +34,10 @@ var recordIDAndReturnFalse = function(id, event) {
return false;
};
var LISTENER = jest.fn();
var ON_CLICK_KEY = keyOf({onClick: null});
var ON_TOUCH_TAP_KEY = keyOf({onTouchTap: null});
var ON_CHANGE_KEY = keyOf({onChange: null});
var ON_MOUSE_ENTER_KEY = keyOf({onMouseEnter: null});
var ON_CLICK_KEY = 'onClick';
var ON_TOUCH_TAP_KEY = 'onTouchTap';
var ON_CHANGE_KEY = 'onChange';
var ON_MOUSE_ENTER_KEY = 'onMouseEnter';

var GRANDPARENT;
var PARENT;
Expand Down
18 changes: 8 additions & 10 deletions src/renderers/dom/client/eventPlugins/BeforeInputEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ var FallbackCompositionState = require('FallbackCompositionState');
var SyntheticCompositionEvent = require('SyntheticCompositionEvent');
var SyntheticInputEvent = require('SyntheticInputEvent');

var keyOf = require('keyOf');

import type { TopLevelTypes } from 'EventConstants';

var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
Expand Down Expand Up @@ -75,8 +73,8 @@ var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
var eventTypes = {
beforeInput: {
phasedRegistrationNames: {
bubbled: keyOf({onBeforeInput: null}),
captured: keyOf({onBeforeInputCapture: null}),
bubbled: 'onBeforeInput',
captured: 'onBeforeInputCapture',
},
dependencies: [
'topCompositionEnd',
Expand All @@ -87,8 +85,8 @@ var eventTypes = {
},
compositionEnd: {
phasedRegistrationNames: {
bubbled: keyOf({onCompositionEnd: null}),
captured: keyOf({onCompositionEndCapture: null}),
bubbled: 'onCompositionEnd',
captured: 'onCompositionEndCapture',
},
dependencies: [
'topBlur',
Expand All @@ -101,8 +99,8 @@ var eventTypes = {
},
compositionStart: {
phasedRegistrationNames: {
bubbled: keyOf({onCompositionStart: null}),
captured: keyOf({onCompositionStartCapture: null}),
bubbled: 'onCompositionStart',
captured: 'onCompositionStartCapture',
},
dependencies: [
'topBlur',
Expand All @@ -115,8 +113,8 @@ var eventTypes = {
},
compositionUpdate: {
phasedRegistrationNames: {
bubbled: keyOf({onCompositionUpdate: null}),
captured: keyOf({onCompositionUpdateCapture: null}),
bubbled: 'onCompositionUpdate',
captured: 'onCompositionUpdateCapture',
},
dependencies: [
'topBlur',
Expand Down
6 changes: 2 additions & 4 deletions src/renderers/dom/client/eventPlugins/ChangeEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ var inputValueTracking = require('inputValueTracking');
var getEventTarget = require('getEventTarget');
var isEventSupported = require('isEventSupported');
var isTextInputElement = require('isTextInputElement');
var keyOf = require('keyOf');


var eventTypes = {
change: {
phasedRegistrationNames: {
bubbled: keyOf({onChange: null}),
captured: keyOf({onChangeCapture: null}),
bubbled: 'onChange',
captured: 'onChangeCapture',
},
dependencies: [
'topBlur',
Expand Down
16 changes: 7 additions & 9 deletions src/renderers/dom/client/eventPlugins/DefaultEventPluginOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

var keyOf = require('keyOf');

/**
* Module that is injectable into `EventPluginHub`, that specifies a
* deterministic ordering of `EventPlugin`s. A convenient way to reason about
Expand All @@ -23,13 +21,13 @@ var keyOf = require('keyOf');
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
*/
var DefaultEventPluginOrder = [
keyOf({ResponderEventPlugin: null}),
keyOf({SimpleEventPlugin: null}),
keyOf({TapEventPlugin: null}),
keyOf({EnterLeaveEventPlugin: null}),
keyOf({ChangeEventPlugin: null}),
keyOf({SelectEventPlugin: null}),
keyOf({BeforeInputEventPlugin: null}),
'ResponderEventPlugin',
'SimpleEventPlugin',
'TapEventPlugin',
'EnterLeaveEventPlugin',
'ChangeEventPlugin',
'SelectEventPlugin',
'BeforeInputEventPlugin',
];

module.exports = DefaultEventPluginOrder;
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ var EventPropagators = require('EventPropagators');
var ReactDOMComponentTree = require('ReactDOMComponentTree');
var SyntheticMouseEvent = require('SyntheticMouseEvent');

var keyOf = require('keyOf');

var eventTypes = {
mouseEnter: {
registrationName: keyOf({onMouseEnter: null}),
registrationName: 'onMouseEnter',
dependencies: [
'topMouseOut',
'topMouseOver',
],
},
mouseLeave: {
registrationName: keyOf({onMouseLeave: null}),
registrationName: 'onMouseLeave',
dependencies: [
'topMouseOut',
'topMouseOver',
Expand Down
8 changes: 3 additions & 5 deletions src/renderers/dom/client/eventPlugins/SelectEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var SyntheticEvent = require('SyntheticEvent');

var getActiveElement = require('getActiveElement');
var isTextInputElement = require('isTextInputElement');
var keyOf = require('keyOf');
var shallowEqual = require('shallowEqual');

var skipSelectionChangeEvent = (
Expand All @@ -31,8 +30,8 @@ var skipSelectionChangeEvent = (
var eventTypes = {
select: {
phasedRegistrationNames: {
bubbled: keyOf({onSelect: null}),
captured: keyOf({onSelectCapture: null}),
bubbled: 'onSelect',
captured: 'onSelectCapture',
},
dependencies: [
'topBlur',
Expand All @@ -55,7 +54,6 @@ var mouseDown = false;
// Track whether a listener exists for this plugin. If none exist, we do
// not extract events. See #3639.
var hasListener = false;
var ON_SELECT_KEY = keyOf({onSelect: null});

/**
* Get an object which is a unique representation of the current selection.
Expand Down Expand Up @@ -212,7 +210,7 @@ var SelectEventPlugin = {
},

didPutListener: function(inst, registrationName, listener) {
if (registrationName === ON_SELECT_KEY) {
if (registrationName === 'onSelect') {
hasListener = true;
}
},
Expand Down
Loading

0 comments on commit f7076b7

Please sign in to comment.