react 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/addons.js +0 -3
- package/lib/AutoFocusMixin.js +32 -0
- package/lib/CSSCore.js +23 -22
- package/lib/CSSProperty.js +32 -1
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/ChangeEventPlugin.js +27 -5
- package/lib/ClientReactRootIndex.js +30 -0
- package/lib/CompositionEventPlugin.js +58 -10
- package/lib/DOMChildrenOperations.js +39 -3
- package/lib/DOMProperty.js +9 -5
- package/lib/DOMPropertyOperations.js +21 -8
- package/lib/Danger.js +9 -8
- package/lib/DefaultDOMPropertyConfig.js +23 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +38 -5
- package/lib/EventConstants.js +4 -1
- package/lib/EventListener.js +42 -34
- package/lib/EventPluginHub.js +118 -13
- package/lib/EventPluginRegistry.js +62 -18
- package/lib/EventPluginUtils.js +33 -4
- package/lib/EventPropagators.js +7 -43
- package/lib/ExecutionEnvironment.js +4 -1
- package/lib/LinkedStateMixin.js +1 -1
- package/lib/LinkedValueUtils.js +160 -0
- package/lib/MobileSafariClickEventPlugin.js +1 -1
- package/lib/PooledClass.js +7 -1
- package/lib/React.js +30 -4
- package/lib/ReactBrowserComponentMixin.js +42 -0
- package/lib/ReactCSSTransitionGroup.js +65 -0
- package/lib/{ReactTransitionableChild.js → ReactCSSTransitionGroupChild.js} +22 -36
- package/lib/ReactChildren.js +4 -4
- package/lib/ReactComponent.js +163 -83
- package/lib/ReactComponentBrowserEnvironment.js +55 -71
- package/lib/ReactCompositeComponent.js +686 -119
- package/lib/ReactContext.js +67 -0
- package/lib/ReactCurrentOwner.js +1 -1
- package/lib/ReactDOM.js +19 -6
- package/lib/ReactDOMButton.js +6 -1
- package/lib/ReactDOMComponent.js +66 -24
- package/lib/ReactDOMForm.js +13 -3
- package/lib/ReactDOMIDOperations.js +106 -61
- package/lib/ReactDOMImg.js +61 -0
- package/lib/ReactDOMInput.js +28 -15
- package/lib/ReactDOMOption.js +13 -8
- package/lib/ReactDOMSelect.js +38 -18
- package/lib/ReactDOMSelection.js +1 -1
- package/lib/ReactDOMTextarea.js +19 -11
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +60 -26
- package/lib/ReactDefaultPerf.js +208 -371
- package/lib/ReactDefaultPerfAnalysis.js +199 -0
- package/lib/ReactErrorUtils.js +6 -15
- package/lib/ReactEventEmitter.js +144 -146
- package/lib/ReactEventEmitterMixin.js +1 -33
- package/lib/ReactEventTopLevelCallback.js +75 -15
- package/lib/ReactInjection.js +43 -0
- package/lib/ReactInputSelection.js +3 -2
- package/lib/ReactInstanceHandles.js +36 -20
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +136 -104
- package/lib/ReactMountReady.js +2 -2
- package/lib/ReactMultiChild.js +40 -49
- package/lib/ReactMultiChildUpdateTypes.js +3 -1
- package/lib/ReactOwner.js +17 -4
- package/lib/ReactPerf.js +6 -9
- package/lib/ReactPropTransferer.js +41 -22
- package/lib/ReactPropTypeLocationNames.js +31 -0
- package/lib/{ReactComponentEnvironment.js → ReactPropTypeLocations.js} +11 -6
- package/lib/ReactPropTypes.js +249 -48
- package/lib/ReactPutListenerQueue.js +61 -0
- package/lib/ReactReconcileTransaction.js +28 -7
- package/lib/ReactRootIndex.js +36 -0
- package/lib/ReactServerRendering.js +46 -19
- package/lib/ReactServerRenderingTransaction.js +116 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +394 -0
- package/lib/ReactTextComponent.js +33 -6
- package/lib/{ReactTransitionKeySet.js → ReactTransitionChildMapping.js} +43 -48
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +133 -58
- package/lib/ReactUpdates.js +15 -12
- package/lib/ReactWithAddons.js +15 -3
- package/lib/SelectEventPlugin.js +23 -40
- package/lib/ServerReactRootIndex.js +36 -0
- package/lib/SimpleEventPlugin.js +55 -7
- package/lib/SyntheticClipboardEvent.js +8 -2
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +44 -0
- package/lib/SyntheticEvent.js +3 -2
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticKeyboardEvent.js +5 -3
- package/lib/SyntheticMouseEvent.js +1 -1
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/SyntheticWheelEvent.js +11 -8
- package/lib/Transaction.js +62 -37
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +1 -1
- package/lib/adler32.js +1 -1
- package/lib/cloneWithProps.js +59 -0
- package/lib/containsNode.js +1 -1
- package/lib/copyProperties.js +1 -1
- package/lib/createArrayFrom.js +11 -14
- package/lib/createFullPageComponent.js +63 -0
- package/lib/createNodesFromMarkup.js +1 -1
- package/lib/createObjectFrom.js +1 -1
- package/lib/cx.js +3 -3
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/emptyFunction.js +1 -1
- package/lib/emptyObject.js +27 -0
- package/lib/escapeTextForBrowser.js +1 -1
- package/lib/flattenChildren.js +6 -3
- package/lib/focusNode.js +33 -0
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getActiveElement.js +5 -4
- package/lib/getEventKey.js +85 -0
- package/lib/getEventTarget.js +1 -1
- package/lib/getMarkupWrap.js +11 -1
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getReactRootElementInContainer.js +1 -1
- package/lib/getTextContentAccessor.js +6 -4
- package/lib/getUnboundedScrollPosition.js +3 -3
- package/lib/hyphenate.js +1 -1
- package/lib/instantiateReactComponent.js +70 -0
- package/lib/invariant.js +20 -12
- package/lib/isEventSupported.js +8 -12
- package/lib/isNode.js +2 -2
- package/lib/isTextInputElement.js +1 -1
- package/lib/isTextNode.js +1 -1
- package/lib/joinClasses.js +1 -1
- package/lib/keyMirror.js +1 -1
- package/lib/keyOf.js +1 -1
- package/lib/memoizeStringOnly.js +1 -1
- package/lib/merge.js +1 -1
- package/lib/mergeHelpers.js +6 -7
- package/lib/mergeInto.js +1 -1
- package/lib/mixInto.js +1 -1
- package/lib/monitorCodeUse.js +37 -0
- package/lib/objMap.js +1 -1
- package/lib/objMapKeyVal.js +1 -1
- package/lib/onlyChild.js +43 -0
- package/lib/performanceNow.js +1 -1
- package/lib/shallowEqual.js +1 -1
- package/lib/shouldUpdateReactComponent.js +61 -0
- package/lib/toArray.js +75 -0
- package/lib/traverseAllChildren.js +72 -9
- package/lib/update.js +159 -0
- package/lib/warning.js +48 -0
- package/package.json +3 -3
- package/react.js +0 -3
- package/ReactJSErrors.js +0 -40
- package/lib/$.js +0 -46
- package/lib/CallbackRegistry.js +0 -91
- package/lib/LinkedValueMixin.js +0 -68
- package/lib/ex.js +0 -49
- package/lib/filterAttributes.js +0 -45
- package/lib/ge.js +0 -76
- package/lib/mutateHTMLNodeWithMarkup.js +0 -100
package/lib/EventPluginHub.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -18,15 +18,20 @@
|
|
|
18
18
|
|
|
19
19
|
"use strict";
|
|
20
20
|
|
|
21
|
-
var CallbackRegistry = require("./CallbackRegistry");
|
|
22
21
|
var EventPluginRegistry = require("./EventPluginRegistry");
|
|
23
22
|
var EventPluginUtils = require("./EventPluginUtils");
|
|
24
|
-
var EventPropagators = require("./EventPropagators");
|
|
25
23
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
26
24
|
|
|
27
25
|
var accumulate = require("./accumulate");
|
|
28
26
|
var forEachAccumulated = require("./forEachAccumulated");
|
|
29
27
|
var invariant = require("./invariant");
|
|
28
|
+
var isEventSupported = require("./isEventSupported");
|
|
29
|
+
var monitorCodeUse = require("./monitorCodeUse");
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Internal store for event listeners
|
|
33
|
+
*/
|
|
34
|
+
var listenerBank = {};
|
|
30
35
|
|
|
31
36
|
/**
|
|
32
37
|
* Internal queue of events that have accumulated their dispatches and are
|
|
@@ -56,6 +61,21 @@ var executeDispatchesAndRelease = function(event) {
|
|
|
56
61
|
}
|
|
57
62
|
};
|
|
58
63
|
|
|
64
|
+
/**
|
|
65
|
+
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
|
|
66
|
+
* hierarchy given ids of the logical DOM elements involved.
|
|
67
|
+
*/
|
|
68
|
+
var InstanceHandle = null;
|
|
69
|
+
|
|
70
|
+
function validateInstanceHandle() {
|
|
71
|
+
var invalid = !InstanceHandle||
|
|
72
|
+
!InstanceHandle.traverseTwoPhase ||
|
|
73
|
+
!InstanceHandle.traverseEnterLeave;
|
|
74
|
+
if (invalid) {
|
|
75
|
+
throw new Error('InstanceHandle not injected before use!');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
59
79
|
/**
|
|
60
80
|
* This is a unified interface for event plugins to be installed and configured.
|
|
61
81
|
*
|
|
@@ -85,11 +105,29 @@ var EventPluginHub = {
|
|
|
85
105
|
*/
|
|
86
106
|
injection: {
|
|
87
107
|
|
|
108
|
+
/**
|
|
109
|
+
* @param {object} InjectedMount
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
injectMount: EventPluginUtils.injection.injectMount,
|
|
113
|
+
|
|
88
114
|
/**
|
|
89
115
|
* @param {object} InjectedInstanceHandle
|
|
90
116
|
* @public
|
|
91
117
|
*/
|
|
92
|
-
injectInstanceHandle:
|
|
118
|
+
injectInstanceHandle: function(InjectedInstanceHandle) {
|
|
119
|
+
InstanceHandle = InjectedInstanceHandle;
|
|
120
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
121
|
+
validateInstanceHandle();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
getInstanceHandle: function() {
|
|
126
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
127
|
+
validateInstanceHandle();
|
|
128
|
+
}
|
|
129
|
+
return InstanceHandle;
|
|
130
|
+
},
|
|
93
131
|
|
|
94
132
|
/**
|
|
95
133
|
* @param {array} InjectedEventPluginOrder
|
|
@@ -104,15 +142,75 @@ var EventPluginHub = {
|
|
|
104
142
|
|
|
105
143
|
},
|
|
106
144
|
|
|
107
|
-
|
|
145
|
+
eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
|
|
108
146
|
|
|
109
|
-
|
|
147
|
+
registrationNameModules: EventPluginRegistry.registrationNameModules,
|
|
110
148
|
|
|
111
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
|
|
151
|
+
*
|
|
152
|
+
* @param {string} id ID of the DOM element.
|
|
153
|
+
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
154
|
+
* @param {?function} listener The callback to store.
|
|
155
|
+
*/
|
|
156
|
+
putListener: function(id, registrationName, listener) {
|
|
157
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
158
|
+
ExecutionEnvironment.canUseDOM,
|
|
159
|
+
'Cannot call putListener() in a non-DOM environment.'
|
|
160
|
+
) : invariant(ExecutionEnvironment.canUseDOM));
|
|
161
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
162
|
+
!listener || typeof listener === 'function',
|
|
163
|
+
'Expected %s listener to be a function, instead got type %s',
|
|
164
|
+
registrationName, typeof listener
|
|
165
|
+
) : invariant(!listener || typeof listener === 'function'));
|
|
112
166
|
|
|
113
|
-
|
|
167
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
168
|
+
// IE8 has no API for event capturing and the `onScroll` event doesn't
|
|
169
|
+
// bubble.
|
|
170
|
+
if (registrationName === 'onScroll' &&
|
|
171
|
+
!isEventSupported('scroll', true)) {
|
|
172
|
+
monitorCodeUse('react_no_scroll_event');
|
|
173
|
+
console.warn('This browser doesn\'t support the `onScroll` event');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
var bankForRegistrationName =
|
|
177
|
+
listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
|
178
|
+
bankForRegistrationName[id] = listener;
|
|
179
|
+
},
|
|
114
180
|
|
|
115
|
-
|
|
181
|
+
/**
|
|
182
|
+
* @param {string} id ID of the DOM element.
|
|
183
|
+
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
184
|
+
* @return {?function} The stored callback.
|
|
185
|
+
*/
|
|
186
|
+
getListener: function(id, registrationName) {
|
|
187
|
+
var bankForRegistrationName = listenerBank[registrationName];
|
|
188
|
+
return bankForRegistrationName && bankForRegistrationName[id];
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Deletes a listener from the registration bank.
|
|
193
|
+
*
|
|
194
|
+
* @param {string} id ID of the DOM element.
|
|
195
|
+
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
196
|
+
*/
|
|
197
|
+
deleteListener: function(id, registrationName) {
|
|
198
|
+
var bankForRegistrationName = listenerBank[registrationName];
|
|
199
|
+
if (bankForRegistrationName) {
|
|
200
|
+
delete bankForRegistrationName[id];
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Deletes all listeners for the DOM element with the supplied ID.
|
|
206
|
+
*
|
|
207
|
+
* @param {string} id ID of the DOM element.
|
|
208
|
+
*/
|
|
209
|
+
deleteAllListeners: function(id) {
|
|
210
|
+
for (var registrationName in listenerBank) {
|
|
211
|
+
delete listenerBank[registrationName][id];
|
|
212
|
+
}
|
|
213
|
+
},
|
|
116
214
|
|
|
117
215
|
/**
|
|
118
216
|
* Allows registered plugins an opportunity to extract events from top-level
|
|
@@ -179,12 +277,19 @@ var EventPluginHub = {
|
|
|
179
277
|
'processEventQueue(): Additional events were enqueued while processing ' +
|
|
180
278
|
'an event queue. Support for this has not yet been implemented.'
|
|
181
279
|
) : invariant(!eventQueue));
|
|
280
|
+
},
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* These are needed for tests only. Do not use!
|
|
284
|
+
*/
|
|
285
|
+
__purge: function() {
|
|
286
|
+
listenerBank = {};
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
__getListenerBank: function() {
|
|
290
|
+
return listenerBank;
|
|
182
291
|
}
|
|
183
292
|
|
|
184
293
|
};
|
|
185
294
|
|
|
186
|
-
if (ExecutionEnvironment.canUseDOM) {
|
|
187
|
-
window.EventPluginHub = EventPluginHub;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
295
|
module.exports = EventPluginHub;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -63,11 +63,19 @@ function recomputePluginOrdering() {
|
|
|
63
63
|
var publishedEvents = PluginModule.eventTypes;
|
|
64
64
|
for (var eventName in publishedEvents) {
|
|
65
65
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
66
|
-
publishEventForPlugin(
|
|
66
|
+
publishEventForPlugin(
|
|
67
|
+
publishedEvents[eventName],
|
|
68
|
+
PluginModule,
|
|
69
|
+
eventName
|
|
70
|
+
),
|
|
67
71
|
'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
|
|
68
72
|
eventName,
|
|
69
73
|
pluginName
|
|
70
|
-
) : invariant(publishEventForPlugin(
|
|
74
|
+
) : invariant(publishEventForPlugin(
|
|
75
|
+
publishedEvents[eventName],
|
|
76
|
+
PluginModule,
|
|
77
|
+
eventName
|
|
78
|
+
)));
|
|
71
79
|
}
|
|
72
80
|
}
|
|
73
81
|
}
|
|
@@ -80,18 +88,34 @@ function recomputePluginOrdering() {
|
|
|
80
88
|
* @return {boolean} True if the event was successfully published.
|
|
81
89
|
* @private
|
|
82
90
|
*/
|
|
83
|
-
function publishEventForPlugin(dispatchConfig, PluginModule) {
|
|
91
|
+
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
|
92
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
93
|
+
!EventPluginRegistry.eventNameDispatchConfigs[eventName],
|
|
94
|
+
'EventPluginHub: More than one plugin attempted to publish the same ' +
|
|
95
|
+
'event name, `%s`.',
|
|
96
|
+
eventName
|
|
97
|
+
) : invariant(!EventPluginRegistry.eventNameDispatchConfigs[eventName]));
|
|
98
|
+
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
|
|
99
|
+
|
|
84
100
|
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
|
|
85
101
|
if (phasedRegistrationNames) {
|
|
86
102
|
for (var phaseName in phasedRegistrationNames) {
|
|
87
103
|
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
|
|
88
104
|
var phasedRegistrationName = phasedRegistrationNames[phaseName];
|
|
89
|
-
publishRegistrationName(
|
|
105
|
+
publishRegistrationName(
|
|
106
|
+
phasedRegistrationName,
|
|
107
|
+
PluginModule,
|
|
108
|
+
eventName
|
|
109
|
+
);
|
|
90
110
|
}
|
|
91
111
|
}
|
|
92
112
|
return true;
|
|
93
113
|
} else if (dispatchConfig.registrationName) {
|
|
94
|
-
publishRegistrationName(
|
|
114
|
+
publishRegistrationName(
|
|
115
|
+
dispatchConfig.registrationName,
|
|
116
|
+
PluginModule,
|
|
117
|
+
eventName
|
|
118
|
+
);
|
|
95
119
|
return true;
|
|
96
120
|
}
|
|
97
121
|
return false;
|
|
@@ -105,14 +129,16 @@ function publishEventForPlugin(dispatchConfig, PluginModule) {
|
|
|
105
129
|
* @param {object} PluginModule Plugin publishing the event.
|
|
106
130
|
* @private
|
|
107
131
|
*/
|
|
108
|
-
function publishRegistrationName(registrationName, PluginModule) {
|
|
132
|
+
function publishRegistrationName(registrationName, PluginModule, eventName) {
|
|
109
133
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
110
|
-
!EventPluginRegistry.
|
|
134
|
+
!EventPluginRegistry.registrationNameModules[registrationName],
|
|
111
135
|
'EventPluginHub: More than one plugin attempted to publish the same ' +
|
|
112
136
|
'registration name, `%s`.',
|
|
113
137
|
registrationName
|
|
114
|
-
) : invariant(!EventPluginRegistry.
|
|
115
|
-
EventPluginRegistry.
|
|
138
|
+
) : invariant(!EventPluginRegistry.registrationNameModules[registrationName]));
|
|
139
|
+
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
|
|
140
|
+
EventPluginRegistry.registrationNameDependencies[registrationName] =
|
|
141
|
+
PluginModule.eventTypes[eventName].dependencies;
|
|
116
142
|
}
|
|
117
143
|
|
|
118
144
|
/**
|
|
@@ -128,9 +154,19 @@ var EventPluginRegistry = {
|
|
|
128
154
|
plugins: [],
|
|
129
155
|
|
|
130
156
|
/**
|
|
131
|
-
* Mapping from
|
|
157
|
+
* Mapping from event name to dispatch config
|
|
132
158
|
*/
|
|
133
|
-
|
|
159
|
+
eventNameDispatchConfigs: {},
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Mapping from registration name to plugin module
|
|
163
|
+
*/
|
|
164
|
+
registrationNameModules: {},
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Mapping from registration name to event name
|
|
168
|
+
*/
|
|
169
|
+
registrationNameDependencies: {},
|
|
134
170
|
|
|
135
171
|
/**
|
|
136
172
|
* Injects an ordering of plugins (by plugin name). This allows the ordering
|
|
@@ -194,7 +230,7 @@ var EventPluginRegistry = {
|
|
|
194
230
|
getPluginModuleForEvent: function(event) {
|
|
195
231
|
var dispatchConfig = event.dispatchConfig;
|
|
196
232
|
if (dispatchConfig.registrationName) {
|
|
197
|
-
return EventPluginRegistry.
|
|
233
|
+
return EventPluginRegistry.registrationNameModules[
|
|
198
234
|
dispatchConfig.registrationName
|
|
199
235
|
] || null;
|
|
200
236
|
}
|
|
@@ -202,7 +238,7 @@ var EventPluginRegistry = {
|
|
|
202
238
|
if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
|
|
203
239
|
continue;
|
|
204
240
|
}
|
|
205
|
-
var PluginModule = EventPluginRegistry.
|
|
241
|
+
var PluginModule = EventPluginRegistry.registrationNameModules[
|
|
206
242
|
dispatchConfig.phasedRegistrationNames[phase]
|
|
207
243
|
];
|
|
208
244
|
if (PluginModule) {
|
|
@@ -224,10 +260,18 @@ var EventPluginRegistry = {
|
|
|
224
260
|
}
|
|
225
261
|
}
|
|
226
262
|
EventPluginRegistry.plugins.length = 0;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
263
|
+
|
|
264
|
+
var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
|
|
265
|
+
for (var eventName in eventNameDispatchConfigs) {
|
|
266
|
+
if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
|
|
267
|
+
delete eventNameDispatchConfigs[eventName];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
var registrationNameModules = EventPluginRegistry.registrationNameModules;
|
|
272
|
+
for (var registrationName in registrationNameModules) {
|
|
273
|
+
if (registrationNameModules.hasOwnProperty(registrationName)) {
|
|
274
|
+
delete registrationNameModules[registrationName];
|
|
231
275
|
}
|
|
232
276
|
}
|
|
233
277
|
}
|
package/lib/EventPluginUtils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -22,6 +22,28 @@ var EventConstants = require("./EventConstants");
|
|
|
22
22
|
|
|
23
23
|
var invariant = require("./invariant");
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Injected dependencies:
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* - `Mount`: [required] Module that can convert between React dom IDs and
|
|
31
|
+
* actual node references.
|
|
32
|
+
*/
|
|
33
|
+
var injection = {
|
|
34
|
+
Mount: null,
|
|
35
|
+
injectMount: function(InjectedMount) {
|
|
36
|
+
injection.Mount = InjectedMount;
|
|
37
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
38
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
39
|
+
InjectedMount && InjectedMount.getNode,
|
|
40
|
+
'EventPluginUtils.injection.injectMount(...): Injected Mount module ' +
|
|
41
|
+
'is missing getNode.'
|
|
42
|
+
) : invariant(InjectedMount && InjectedMount.getNode));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
25
47
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
26
48
|
|
|
27
49
|
function isEndish(topLevelType) {
|
|
@@ -39,6 +61,7 @@ function isStartish(topLevelType) {
|
|
|
39
61
|
topLevelType === topLevelTypes.topTouchStart;
|
|
40
62
|
}
|
|
41
63
|
|
|
64
|
+
|
|
42
65
|
var validateEventDispatches;
|
|
43
66
|
if ("production" !== process.env.NODE_ENV) {
|
|
44
67
|
validateEventDispatches = function(event) {
|
|
@@ -90,7 +113,10 @@ function forEachEventDispatch(event, cb) {
|
|
|
90
113
|
* @param {string} domID DOM id to pass to the callback.
|
|
91
114
|
*/
|
|
92
115
|
function executeDispatch(event, listener, domID) {
|
|
93
|
-
|
|
116
|
+
event.currentTarget = injection.Mount.getNode(domID);
|
|
117
|
+
var returnValue = listener(event, domID);
|
|
118
|
+
event.currentTarget = null;
|
|
119
|
+
return returnValue;
|
|
94
120
|
}
|
|
95
121
|
|
|
96
122
|
/**
|
|
@@ -175,11 +201,14 @@ var EventPluginUtils = {
|
|
|
175
201
|
isEndish: isEndish,
|
|
176
202
|
isMoveish: isMoveish,
|
|
177
203
|
isStartish: isStartish,
|
|
204
|
+
|
|
205
|
+
executeDirectDispatch: executeDirectDispatch,
|
|
206
|
+
executeDispatch: executeDispatch,
|
|
178
207
|
executeDispatchesInOrder: executeDispatchesInOrder,
|
|
179
208
|
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
|
|
180
|
-
executeDirectDispatch: executeDirectDispatch,
|
|
181
209
|
hasDispatches: hasDispatches,
|
|
182
|
-
|
|
210
|
+
injection: injection,
|
|
211
|
+
useTouchEvents: false
|
|
183
212
|
};
|
|
184
213
|
|
|
185
214
|
module.exports = EventPluginUtils;
|
package/lib/EventPropagators.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -18,39 +18,14 @@
|
|
|
18
18
|
|
|
19
19
|
"use strict";
|
|
20
20
|
|
|
21
|
-
var CallbackRegistry = require("./CallbackRegistry");
|
|
22
21
|
var EventConstants = require("./EventConstants");
|
|
22
|
+
var EventPluginHub = require("./EventPluginHub");
|
|
23
23
|
|
|
24
24
|
var accumulate = require("./accumulate");
|
|
25
25
|
var forEachAccumulated = require("./forEachAccumulated");
|
|
26
|
-
var getListener = CallbackRegistry.getListener;
|
|
27
|
-
var PropagationPhases = EventConstants.PropagationPhases;
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
|
|
35
|
-
* hierarchy given ids of the logical DOM elements involved.
|
|
36
|
-
*/
|
|
37
|
-
var injection = {
|
|
38
|
-
InstanceHandle: null,
|
|
39
|
-
injectInstanceHandle: function(InjectedInstanceHandle) {
|
|
40
|
-
injection.InstanceHandle = InjectedInstanceHandle;
|
|
41
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
42
|
-
injection.validate();
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
validate: function() {
|
|
46
|
-
var invalid = !injection.InstanceHandle||
|
|
47
|
-
!injection.InstanceHandle.traverseTwoPhase ||
|
|
48
|
-
!injection.InstanceHandle.traverseEnterLeave;
|
|
49
|
-
if (invalid) {
|
|
50
|
-
throw new Error('InstanceHandle not injected before use!');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
27
|
+
var PropagationPhases = EventConstants.PropagationPhases;
|
|
28
|
+
var getListener = EventPluginHub.getListener;
|
|
54
29
|
|
|
55
30
|
/**
|
|
56
31
|
* Some event types have a notion of different registration names for different
|
|
@@ -73,7 +48,6 @@ function accumulateDirectionalDispatches(domID, upwards, event) {
|
|
|
73
48
|
if (!domID) {
|
|
74
49
|
throw new Error('Dispatching id must not be null');
|
|
75
50
|
}
|
|
76
|
-
injection.validate();
|
|
77
51
|
}
|
|
78
52
|
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
|
|
79
53
|
var listener = listenerAtPhase(domID, event, phase);
|
|
@@ -92,7 +66,7 @@ function accumulateDirectionalDispatches(domID, upwards, event) {
|
|
|
92
66
|
*/
|
|
93
67
|
function accumulateTwoPhaseDispatchesSingle(event) {
|
|
94
68
|
if (event && event.dispatchConfig.phasedRegistrationNames) {
|
|
95
|
-
injection.
|
|
69
|
+
EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
|
|
96
70
|
event.dispatchMarker,
|
|
97
71
|
accumulateDirectionalDispatches,
|
|
98
72
|
event
|
|
@@ -129,17 +103,11 @@ function accumulateDirectDispatchesSingle(event) {
|
|
|
129
103
|
}
|
|
130
104
|
|
|
131
105
|
function accumulateTwoPhaseDispatches(events) {
|
|
132
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
133
|
-
injection.validate();
|
|
134
|
-
}
|
|
135
106
|
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
|
|
136
107
|
}
|
|
137
108
|
|
|
138
109
|
function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
|
|
139
|
-
|
|
140
|
-
injection.validate();
|
|
141
|
-
}
|
|
142
|
-
injection.InstanceHandle.traverseEnterLeave(
|
|
110
|
+
EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
|
|
143
111
|
fromID,
|
|
144
112
|
toID,
|
|
145
113
|
accumulateDispatches,
|
|
@@ -150,9 +118,6 @@ function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
|
|
|
150
118
|
|
|
151
119
|
|
|
152
120
|
function accumulateDirectDispatches(events) {
|
|
153
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
154
|
-
injection.validate();
|
|
155
|
-
}
|
|
156
121
|
forEachAccumulated(events, accumulateDirectDispatchesSingle);
|
|
157
122
|
}
|
|
158
123
|
|
|
@@ -172,8 +137,7 @@ function accumulateDirectDispatches(events) {
|
|
|
172
137
|
var EventPropagators = {
|
|
173
138
|
accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
|
|
174
139
|
accumulateDirectDispatches: accumulateDirectDispatches,
|
|
175
|
-
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
|
|
176
|
-
injection: injection
|
|
140
|
+
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
|
|
177
141
|
};
|
|
178
142
|
|
|
179
143
|
module.exports = EventPropagators;
|