react 0.14.8 → 15.0.0-rc.1
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/LICENSE +1 -1
- package/addons.js +2 -0
- package/dist/react-with-addons.js +4203 -4148
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4159 -3850
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +4 -1
- package/lib/CSSPropertyOperations.js +24 -10
- package/lib/CallbackQueue.js +13 -2
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +93 -60
- package/lib/DOMLazyTree.js +96 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +87 -53
- package/lib/Danger.js +13 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +22 -66
- package/lib/EventPluginRegistry.js +30 -9
- package/lib/EventPluginUtils.js +61 -36
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +1 -2
- package/lib/HTMLDOMPropertyConfig.js +69 -90
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +5 -6
- package/lib/MetaMatchers.js +2 -2
- package/lib/Object.assign.js +1 -1
- package/lib/OrderedMap.js +14 -14
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +1 -13
- package/lib/ReactBrowserEventEmitter.js +16 -24
- package/lib/ReactCSSTransitionGroup.js +1 -2
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +37 -86
- package/lib/ReactComponent.js +7 -8
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +160 -69
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +188 -244
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +69 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +71 -22
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +11 -10
- package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +61 -0
- package/lib/ReactDOMSelect.js +40 -17
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +84 -43
- package/lib/ReactDOMTextarea.js +36 -9
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +59 -19
- package/lib/ReactDefaultPerfAnalysis.js +17 -9
- package/lib/ReactElement.js +60 -21
- package/lib/ReactElementValidator.js +8 -8
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +20 -75
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +6 -6
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -12
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactIsomorphic.js +1 -1
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +87 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +3 -3
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +27 -3
- package/lib/ReactReconcileTransaction.js +17 -6
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +17 -35
- package/lib/ReactServerRenderingTransaction.js +8 -26
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +33 -24
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +1 -1
- package/lib/ReactUpdateQueue.js +6 -65
- package/lib/ReactUpdates.js +26 -9
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -14
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +1 -2
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +25 -66
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +57 -17
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +97 -17
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +2 -2
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +4 -2
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +2 -2
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +9 -11
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +2 -2
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +2 -2
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +5 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +8 -8
- package/lib/update.js +12 -12
- package/lib/validateDOMNesting.js +15 -11
- package/package.json +2 -2
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
package/lib/EventConstants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -20,6 +20,9 @@ var PropagationPhases = keyMirror({ bubbled: null, captured: null });
|
|
|
20
20
|
*/
|
|
21
21
|
var topLevelTypes = keyMirror({
|
|
22
22
|
topAbort: null,
|
|
23
|
+
topAnimationEnd: null,
|
|
24
|
+
topAnimationIteration: null,
|
|
25
|
+
topAnimationStart: null,
|
|
23
26
|
topBlur: null,
|
|
24
27
|
topCanPlay: null,
|
|
25
28
|
topCanPlayThrough: null,
|
|
@@ -47,6 +50,7 @@ var topLevelTypes = keyMirror({
|
|
|
47
50
|
topError: null,
|
|
48
51
|
topFocus: null,
|
|
49
52
|
topInput: null,
|
|
53
|
+
topInvalid: null,
|
|
50
54
|
topKeyDown: null,
|
|
51
55
|
topKeyPress: null,
|
|
52
56
|
topKeyUp: null,
|
|
@@ -79,6 +83,7 @@ var topLevelTypes = keyMirror({
|
|
|
79
83
|
topTouchEnd: null,
|
|
80
84
|
topTouchMove: null,
|
|
81
85
|
topTouchStart: null,
|
|
86
|
+
topTransitionEnd: null,
|
|
82
87
|
topVolumeChange: null,
|
|
83
88
|
topWaiting: null,
|
|
84
89
|
topWheel: null
|
package/lib/EventPluginHub.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -18,7 +18,6 @@ var ReactErrorUtils = require('./ReactErrorUtils');
|
|
|
18
18
|
var accumulateInto = require('./accumulateInto');
|
|
19
19
|
var forEachAccumulated = require('./forEachAccumulated');
|
|
20
20
|
var invariant = require('fbjs/lib/invariant');
|
|
21
|
-
var warning = require('fbjs/lib/warning');
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* Internal store for event listeners
|
|
@@ -54,17 +53,6 @@ var executeDispatchesAndReleaseTopLevel = function (e) {
|
|
|
54
53
|
return executeDispatchesAndRelease(e, false);
|
|
55
54
|
};
|
|
56
55
|
|
|
57
|
-
/**
|
|
58
|
-
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
|
|
59
|
-
* hierarchy given ids of the logical DOM elements involved.
|
|
60
|
-
*/
|
|
61
|
-
var InstanceHandle = null;
|
|
62
|
-
|
|
63
|
-
function validateInstanceHandle() {
|
|
64
|
-
var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave;
|
|
65
|
-
process.env.NODE_ENV !== 'production' ? warning(valid, 'InstanceHandle not injected before use!') : undefined;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
56
|
/**
|
|
69
57
|
* This is a unified interface for event plugins to be installed and configured.
|
|
70
58
|
*
|
|
@@ -94,30 +82,6 @@ var EventPluginHub = {
|
|
|
94
82
|
*/
|
|
95
83
|
injection: {
|
|
96
84
|
|
|
97
|
-
/**
|
|
98
|
-
* @param {object} InjectedMount
|
|
99
|
-
* @public
|
|
100
|
-
*/
|
|
101
|
-
injectMount: EventPluginUtils.injection.injectMount,
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @param {object} InjectedInstanceHandle
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
|
-
injectInstanceHandle: function (InjectedInstanceHandle) {
|
|
108
|
-
InstanceHandle = InjectedInstanceHandle;
|
|
109
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
110
|
-
validateInstanceHandle();
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
getInstanceHandle: function () {
|
|
115
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
116
|
-
validateInstanceHandle();
|
|
117
|
-
}
|
|
118
|
-
return InstanceHandle;
|
|
119
|
-
},
|
|
120
|
-
|
|
121
85
|
/**
|
|
122
86
|
* @param {array} InjectedEventPluginOrder
|
|
123
87
|
* @public
|
|
@@ -131,75 +95,71 @@ var EventPluginHub = {
|
|
|
131
95
|
|
|
132
96
|
},
|
|
133
97
|
|
|
134
|
-
eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
|
|
135
|
-
|
|
136
|
-
registrationNameModules: EventPluginRegistry.registrationNameModules,
|
|
137
|
-
|
|
138
98
|
/**
|
|
139
99
|
* Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
|
|
140
100
|
*
|
|
141
|
-
* @param {
|
|
101
|
+
* @param {object} inst The instance, which is the source of events.
|
|
142
102
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
143
|
-
* @param {
|
|
103
|
+
* @param {function} listener The callback to store.
|
|
144
104
|
*/
|
|
145
|
-
putListener: function (
|
|
146
|
-
!(typeof listener === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : invariant(false) :
|
|
105
|
+
putListener: function (inst, registrationName, listener) {
|
|
106
|
+
!(typeof listener === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : invariant(false) : void 0;
|
|
147
107
|
|
|
148
108
|
var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
|
149
|
-
bankForRegistrationName[
|
|
109
|
+
bankForRegistrationName[inst._rootNodeID] = listener;
|
|
150
110
|
|
|
151
111
|
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
|
|
152
112
|
if (PluginModule && PluginModule.didPutListener) {
|
|
153
|
-
PluginModule.didPutListener(
|
|
113
|
+
PluginModule.didPutListener(inst, registrationName, listener);
|
|
154
114
|
}
|
|
155
115
|
},
|
|
156
116
|
|
|
157
117
|
/**
|
|
158
|
-
* @param {
|
|
118
|
+
* @param {object} inst The instance, which is the source of events.
|
|
159
119
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
160
120
|
* @return {?function} The stored callback.
|
|
161
121
|
*/
|
|
162
|
-
getListener: function (
|
|
122
|
+
getListener: function (inst, registrationName) {
|
|
163
123
|
var bankForRegistrationName = listenerBank[registrationName];
|
|
164
|
-
return bankForRegistrationName && bankForRegistrationName[
|
|
124
|
+
return bankForRegistrationName && bankForRegistrationName[inst._rootNodeID];
|
|
165
125
|
},
|
|
166
126
|
|
|
167
127
|
/**
|
|
168
128
|
* Deletes a listener from the registration bank.
|
|
169
129
|
*
|
|
170
|
-
* @param {
|
|
130
|
+
* @param {object} inst The instance, which is the source of events.
|
|
171
131
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
172
132
|
*/
|
|
173
|
-
deleteListener: function (
|
|
133
|
+
deleteListener: function (inst, registrationName) {
|
|
174
134
|
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
|
|
175
135
|
if (PluginModule && PluginModule.willDeleteListener) {
|
|
176
|
-
PluginModule.willDeleteListener(
|
|
136
|
+
PluginModule.willDeleteListener(inst, registrationName);
|
|
177
137
|
}
|
|
178
138
|
|
|
179
139
|
var bankForRegistrationName = listenerBank[registrationName];
|
|
180
140
|
// TODO: This should never be null -- when is it?
|
|
181
141
|
if (bankForRegistrationName) {
|
|
182
|
-
delete bankForRegistrationName[
|
|
142
|
+
delete bankForRegistrationName[inst._rootNodeID];
|
|
183
143
|
}
|
|
184
144
|
},
|
|
185
145
|
|
|
186
146
|
/**
|
|
187
147
|
* Deletes all listeners for the DOM element with the supplied ID.
|
|
188
148
|
*
|
|
189
|
-
* @param {
|
|
149
|
+
* @param {object} inst The instance, which is the source of events.
|
|
190
150
|
*/
|
|
191
|
-
deleteAllListeners: function (
|
|
151
|
+
deleteAllListeners: function (inst) {
|
|
192
152
|
for (var registrationName in listenerBank) {
|
|
193
|
-
if (!listenerBank[registrationName][
|
|
153
|
+
if (!listenerBank[registrationName][inst._rootNodeID]) {
|
|
194
154
|
continue;
|
|
195
155
|
}
|
|
196
156
|
|
|
197
157
|
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
|
|
198
158
|
if (PluginModule && PluginModule.willDeleteListener) {
|
|
199
|
-
PluginModule.willDeleteListener(
|
|
159
|
+
PluginModule.willDeleteListener(inst, registrationName);
|
|
200
160
|
}
|
|
201
161
|
|
|
202
|
-
delete listenerBank[registrationName][
|
|
162
|
+
delete listenerBank[registrationName][inst._rootNodeID];
|
|
203
163
|
}
|
|
204
164
|
},
|
|
205
165
|
|
|
@@ -207,21 +167,17 @@ var EventPluginHub = {
|
|
|
207
167
|
* Allows registered plugins an opportunity to extract events from top-level
|
|
208
168
|
* native browser events.
|
|
209
169
|
*
|
|
210
|
-
* @param {string} topLevelType Record from `EventConstants`.
|
|
211
|
-
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
212
|
-
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
213
|
-
* @param {object} nativeEvent Native browser event.
|
|
214
170
|
* @return {*} An accumulation of synthetic events.
|
|
215
171
|
* @internal
|
|
216
172
|
*/
|
|
217
|
-
extractEvents: function (topLevelType,
|
|
173
|
+
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
218
174
|
var events;
|
|
219
175
|
var plugins = EventPluginRegistry.plugins;
|
|
220
176
|
for (var i = 0; i < plugins.length; i++) {
|
|
221
177
|
// Not every plugin in the ordering may be loaded at runtime.
|
|
222
178
|
var possiblePlugin = plugins[i];
|
|
223
179
|
if (possiblePlugin) {
|
|
224
|
-
var extractedEvents = possiblePlugin.extractEvents(topLevelType,
|
|
180
|
+
var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
|
|
225
181
|
if (extractedEvents) {
|
|
226
182
|
events = accumulateInto(events, extractedEvents);
|
|
227
183
|
}
|
|
@@ -258,7 +214,7 @@ var EventPluginHub = {
|
|
|
258
214
|
} else {
|
|
259
215
|
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
|
|
260
216
|
}
|
|
261
|
-
!!eventQueue ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.') : invariant(false) :
|
|
217
|
+
!!eventQueue ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.') : invariant(false) : void 0;
|
|
262
218
|
// This would be a good time to rethrow if any of the event handlers threw.
|
|
263
219
|
ReactErrorUtils.rethrowCaughtError();
|
|
264
220
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule EventPluginRegistry
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -37,15 +36,15 @@ function recomputePluginOrdering() {
|
|
|
37
36
|
for (var pluginName in namesToPlugins) {
|
|
38
37
|
var PluginModule = namesToPlugins[pluginName];
|
|
39
38
|
var pluginIndex = EventPluginOrder.indexOf(pluginName);
|
|
40
|
-
!(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) :
|
|
39
|
+
!(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) : void 0;
|
|
41
40
|
if (EventPluginRegistry.plugins[pluginIndex]) {
|
|
42
41
|
continue;
|
|
43
42
|
}
|
|
44
|
-
!PluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) :
|
|
43
|
+
!PluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) : void 0;
|
|
45
44
|
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
|
|
46
45
|
var publishedEvents = PluginModule.eventTypes;
|
|
47
46
|
for (var eventName in publishedEvents) {
|
|
48
|
-
!publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) :
|
|
47
|
+
!publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) : void 0;
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
}
|
|
@@ -59,7 +58,7 @@ function recomputePluginOrdering() {
|
|
|
59
58
|
* @private
|
|
60
59
|
*/
|
|
61
60
|
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
|
62
|
-
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) :
|
|
61
|
+
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) : void 0;
|
|
63
62
|
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
|
|
64
63
|
|
|
65
64
|
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
|
|
@@ -87,9 +86,14 @@ function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
|
|
87
86
|
* @private
|
|
88
87
|
*/
|
|
89
88
|
function publishRegistrationName(registrationName, PluginModule, eventName) {
|
|
90
|
-
!!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) :
|
|
89
|
+
!!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : void 0;
|
|
91
90
|
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
|
|
92
91
|
EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
|
|
92
|
+
|
|
93
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
94
|
+
var lowerCasedName = registrationName.toLowerCase();
|
|
95
|
+
EventPluginRegistry.possibleRegistrationNames[lowerCasedName] = registrationName;
|
|
96
|
+
}
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
/**
|
|
@@ -119,6 +123,14 @@ var EventPluginRegistry = {
|
|
|
119
123
|
*/
|
|
120
124
|
registrationNameDependencies: {},
|
|
121
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Mapping from lowercase registration names to the properly cased version,
|
|
128
|
+
* used to warn in the case of missing event handlers. Available
|
|
129
|
+
* only in __DEV__.
|
|
130
|
+
* @type {Object}
|
|
131
|
+
*/
|
|
132
|
+
possibleRegistrationNames: process.env.NODE_ENV !== 'production' ? {} : null,
|
|
133
|
+
|
|
122
134
|
/**
|
|
123
135
|
* Injects an ordering of plugins (by plugin name). This allows the ordering
|
|
124
136
|
* to be decoupled from injection of the actual plugins so that ordering is
|
|
@@ -129,7 +141,7 @@ var EventPluginRegistry = {
|
|
|
129
141
|
* @see {EventPluginHub.injection.injectEventPluginOrder}
|
|
130
142
|
*/
|
|
131
143
|
injectEventPluginOrder: function (InjectedEventPluginOrder) {
|
|
132
|
-
!!EventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.') : invariant(false) :
|
|
144
|
+
!!EventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.') : invariant(false) : void 0;
|
|
133
145
|
// Clone the ordering so it cannot be dynamically mutated.
|
|
134
146
|
EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
|
|
135
147
|
recomputePluginOrdering();
|
|
@@ -153,7 +165,7 @@ var EventPluginRegistry = {
|
|
|
153
165
|
}
|
|
154
166
|
var PluginModule = injectedNamesToPlugins[pluginName];
|
|
155
167
|
if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) {
|
|
156
|
-
!!namesToPlugins[pluginName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName) : invariant(false) :
|
|
168
|
+
!!namesToPlugins[pluginName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName) : invariant(false) : void 0;
|
|
157
169
|
namesToPlugins[pluginName] = PluginModule;
|
|
158
170
|
isOrderingDirty = true;
|
|
159
171
|
}
|
|
@@ -213,6 +225,15 @@ var EventPluginRegistry = {
|
|
|
213
225
|
delete registrationNameModules[registrationName];
|
|
214
226
|
}
|
|
215
227
|
}
|
|
228
|
+
|
|
229
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
230
|
+
var possibleRegistrationNames = EventPluginRegistry.possibleRegistrationNames;
|
|
231
|
+
for (var lowerCasedName in possibleRegistrationNames) {
|
|
232
|
+
if (possibleRegistrationNames.hasOwnProperty(lowerCasedName)) {
|
|
233
|
+
delete possibleRegistrationNames[lowerCasedName];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
216
237
|
}
|
|
217
238
|
|
|
218
239
|
};
|
package/lib/EventPluginUtils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -22,15 +22,22 @@ var warning = require('fbjs/lib/warning');
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* - `
|
|
26
|
-
* actual node references.
|
|
25
|
+
* - `ComponentTree`: [required] Module that can convert between React instances
|
|
26
|
+
* and actual node references.
|
|
27
27
|
*/
|
|
28
|
+
var ComponentTree;
|
|
29
|
+
var TreeTraversal;
|
|
28
30
|
var injection = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
injection.Mount = InjectedMount;
|
|
31
|
+
injectComponentTree: function (Injected) {
|
|
32
|
+
ComponentTree = Injected;
|
|
32
33
|
if (process.env.NODE_ENV !== 'production') {
|
|
33
|
-
process.env.NODE_ENV !== 'production' ? warning(
|
|
34
|
+
process.env.NODE_ENV !== 'production' ? warning(Injected && Injected.getNodeFromInstance && Injected.getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
injectTreeTraversal: function (Injected) {
|
|
38
|
+
TreeTraversal = Injected;
|
|
39
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
40
|
+
process.env.NODE_ENV !== 'production' ? warning(Injected && Injected.isAncestor && Injected.getLowestCommonAncestor, 'EventPluginUtils.injection.injectTreeTraversal(...): Injected ' + 'module is missing isAncestor or getLowestCommonAncestor.') : void 0;
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
};
|
|
@@ -52,14 +59,15 @@ var validateEventDispatches;
|
|
|
52
59
|
if (process.env.NODE_ENV !== 'production') {
|
|
53
60
|
validateEventDispatches = function (event) {
|
|
54
61
|
var dispatchListeners = event._dispatchListeners;
|
|
55
|
-
var
|
|
62
|
+
var dispatchInstances = event._dispatchInstances;
|
|
56
63
|
|
|
57
64
|
var listenersIsArr = Array.isArray(dispatchListeners);
|
|
58
|
-
var idsIsArr = Array.isArray(dispatchIDs);
|
|
59
|
-
var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
|
|
60
65
|
var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
var instancesIsArr = Array.isArray(dispatchInstances);
|
|
68
|
+
var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
|
|
69
|
+
|
|
70
|
+
process.env.NODE_ENV !== 'production' ? warning(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : void 0;
|
|
63
71
|
};
|
|
64
72
|
}
|
|
65
73
|
|
|
@@ -68,15 +76,15 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
68
76
|
* @param {SyntheticEvent} event SyntheticEvent to handle
|
|
69
77
|
* @param {boolean} simulated If the event is simulated (changes exn behavior)
|
|
70
78
|
* @param {function} listener Application-level callback
|
|
71
|
-
* @param {
|
|
79
|
+
* @param {*} inst Internal component instance
|
|
72
80
|
*/
|
|
73
|
-
function executeDispatch(event, simulated, listener,
|
|
81
|
+
function executeDispatch(event, simulated, listener, inst) {
|
|
74
82
|
var type = event.type || 'unknown-event';
|
|
75
|
-
event.currentTarget =
|
|
83
|
+
event.currentTarget = EventPluginUtils.getNodeFromInstance(inst);
|
|
76
84
|
if (simulated) {
|
|
77
|
-
ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event
|
|
85
|
+
ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event);
|
|
78
86
|
} else {
|
|
79
|
-
ReactErrorUtils.invokeGuardedCallback(type, listener, event
|
|
87
|
+
ReactErrorUtils.invokeGuardedCallback(type, listener, event);
|
|
80
88
|
}
|
|
81
89
|
event.currentTarget = null;
|
|
82
90
|
}
|
|
@@ -86,7 +94,7 @@ function executeDispatch(event, simulated, listener, domID) {
|
|
|
86
94
|
*/
|
|
87
95
|
function executeDispatchesInOrder(event, simulated) {
|
|
88
96
|
var dispatchListeners = event._dispatchListeners;
|
|
89
|
-
var
|
|
97
|
+
var dispatchInstances = event._dispatchInstances;
|
|
90
98
|
if (process.env.NODE_ENV !== 'production') {
|
|
91
99
|
validateEventDispatches(event);
|
|
92
100
|
}
|
|
@@ -95,14 +103,14 @@ function executeDispatchesInOrder(event, simulated) {
|
|
|
95
103
|
if (event.isPropagationStopped()) {
|
|
96
104
|
break;
|
|
97
105
|
}
|
|
98
|
-
// Listeners and
|
|
99
|
-
executeDispatch(event, simulated, dispatchListeners[i],
|
|
106
|
+
// Listeners and Instances are two parallel arrays that are always in sync.
|
|
107
|
+
executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]);
|
|
100
108
|
}
|
|
101
109
|
} else if (dispatchListeners) {
|
|
102
|
-
executeDispatch(event, simulated, dispatchListeners,
|
|
110
|
+
executeDispatch(event, simulated, dispatchListeners, dispatchInstances);
|
|
103
111
|
}
|
|
104
112
|
event._dispatchListeners = null;
|
|
105
|
-
event.
|
|
113
|
+
event._dispatchInstances = null;
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
/**
|
|
@@ -114,7 +122,7 @@ function executeDispatchesInOrder(event, simulated) {
|
|
|
114
122
|
*/
|
|
115
123
|
function executeDispatchesInOrderStopAtTrueImpl(event) {
|
|
116
124
|
var dispatchListeners = event._dispatchListeners;
|
|
117
|
-
var
|
|
125
|
+
var dispatchInstances = event._dispatchInstances;
|
|
118
126
|
if (process.env.NODE_ENV !== 'production') {
|
|
119
127
|
validateEventDispatches(event);
|
|
120
128
|
}
|
|
@@ -123,14 +131,14 @@ function executeDispatchesInOrderStopAtTrueImpl(event) {
|
|
|
123
131
|
if (event.isPropagationStopped()) {
|
|
124
132
|
break;
|
|
125
133
|
}
|
|
126
|
-
// Listeners and
|
|
127
|
-
if (dispatchListeners[i](event,
|
|
128
|
-
return
|
|
134
|
+
// Listeners and Instances are two parallel arrays that are always in sync.
|
|
135
|
+
if (dispatchListeners[i](event, dispatchInstances[i])) {
|
|
136
|
+
return dispatchInstances[i];
|
|
129
137
|
}
|
|
130
138
|
}
|
|
131
139
|
} else if (dispatchListeners) {
|
|
132
|
-
if (dispatchListeners(event,
|
|
133
|
-
return
|
|
140
|
+
if (dispatchListeners(event, dispatchInstances)) {
|
|
141
|
+
return dispatchInstances;
|
|
134
142
|
}
|
|
135
143
|
}
|
|
136
144
|
return null;
|
|
@@ -141,7 +149,7 @@ function executeDispatchesInOrderStopAtTrueImpl(event) {
|
|
|
141
149
|
*/
|
|
142
150
|
function executeDispatchesInOrderStopAtTrue(event) {
|
|
143
151
|
var ret = executeDispatchesInOrderStopAtTrueImpl(event);
|
|
144
|
-
event.
|
|
152
|
+
event._dispatchInstances = null;
|
|
145
153
|
event._dispatchListeners = null;
|
|
146
154
|
return ret;
|
|
147
155
|
}
|
|
@@ -160,11 +168,13 @@ function executeDirectDispatch(event) {
|
|
|
160
168
|
validateEventDispatches(event);
|
|
161
169
|
}
|
|
162
170
|
var dispatchListener = event._dispatchListeners;
|
|
163
|
-
var
|
|
164
|
-
!!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) :
|
|
165
|
-
|
|
171
|
+
var dispatchInstance = event._dispatchInstances;
|
|
172
|
+
!!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) : void 0;
|
|
173
|
+
event.currentTarget = EventPluginUtils.getNodeFromInstance(dispatchInstance);
|
|
174
|
+
var res = dispatchListener ? dispatchListener(event) : null;
|
|
175
|
+
event.curentTarget = null;
|
|
166
176
|
event._dispatchListeners = null;
|
|
167
|
-
event.
|
|
177
|
+
event._dispatchInstances = null;
|
|
168
178
|
return res;
|
|
169
179
|
}
|
|
170
180
|
|
|
@@ -189,11 +199,26 @@ var EventPluginUtils = {
|
|
|
189
199
|
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
|
|
190
200
|
hasDispatches: hasDispatches,
|
|
191
201
|
|
|
192
|
-
|
|
193
|
-
return
|
|
202
|
+
getInstanceFromNode: function (node) {
|
|
203
|
+
return ComponentTree.getInstanceFromNode(node);
|
|
204
|
+
},
|
|
205
|
+
getNodeFromInstance: function (node) {
|
|
206
|
+
return ComponentTree.getNodeFromInstance(node);
|
|
207
|
+
},
|
|
208
|
+
isAncestor: function (a, b) {
|
|
209
|
+
return TreeTraversal.isAncestor(a, b);
|
|
210
|
+
},
|
|
211
|
+
getLowestCommonAncestor: function (a, b) {
|
|
212
|
+
return TreeTraversal.getLowestCommonAncestor(a, b);
|
|
213
|
+
},
|
|
214
|
+
getParentInstance: function (inst) {
|
|
215
|
+
return TreeTraversal.getParentInstance(inst);
|
|
216
|
+
},
|
|
217
|
+
traverseTwoPhase: function (target, fn, arg) {
|
|
218
|
+
return TreeTraversal.traverseTwoPhase(target, fn, arg);
|
|
194
219
|
},
|
|
195
|
-
|
|
196
|
-
return
|
|
220
|
+
traverseEnterLeave: function (from, to, fn, argFrom, argTo) {
|
|
221
|
+
return TreeTraversal.traverseEnterLeave(from, to, fn, argFrom, argTo);
|
|
197
222
|
},
|
|
198
223
|
|
|
199
224
|
injection: injection
|