react 0.14.0-beta2 → 0.14.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/README.md +4 -4
- package/addons.js +3 -1
- package/dist/react-with-addons.js +1944 -1375
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +1704 -1250
- package/dist/react.min.js +6 -6
- package/lib/CSSProperty.js +15 -3
- package/lib/CSSPropertyOperations.js +15 -2
- package/lib/ChangeEventPlugin.js +5 -2
- package/lib/DOMChildrenOperations.js +12 -1
- package/lib/DOMPropertyOperations.js +14 -1
- package/lib/Danger.js +9 -4
- package/lib/EnterLeaveEventPlugin.js +13 -5
- package/lib/EventConstants.js +2 -2
- package/lib/EventPluginHub.js +18 -10
- package/lib/EventPluginUtils.js +23 -27
- package/lib/EventPropagators.js +1 -1
- package/lib/FallbackCompositionState.js +6 -0
- package/lib/HTMLDOMPropertyConfig.js +25 -2
- package/lib/PooledClass.js +1 -3
- package/lib/React.js +14 -3
- package/lib/ReactBrowserComponentMixin.js +1 -1
- package/lib/ReactBrowserEventEmitter.js +10 -4
- package/lib/ReactCSSTransitionGroup.js +33 -18
- package/lib/ReactCSSTransitionGroupChild.js +42 -25
- package/lib/ReactChildReconciler.js +3 -5
- package/lib/ReactChildren.js +70 -30
- package/lib/ReactClass.js +6 -6
- package/lib/ReactComponent.js +7 -6
- package/lib/ReactCompositeComponent.js +58 -7
- package/lib/ReactDOM.js +7 -5
- package/lib/ReactDOMComponent.js +140 -46
- package/lib/ReactDOMFeatureFlags.js +18 -0
- package/lib/ReactDOMIDOperations.js +1 -60
- package/lib/ReactDOMInput.js +10 -1
- package/lib/ReactDOMSelect.js +1 -1
- package/lib/ReactDOMSelection.js +16 -0
- package/lib/ReactDOMServer.js +3 -1
- package/lib/ReactDOMTextComponent.js +23 -10
- package/lib/ReactDOMTextarea.js +3 -1
- package/lib/ReactDefaultInjection.js +0 -2
- package/lib/ReactDefaultPerf.js +10 -4
- package/lib/ReactDefaultPerfAnalysis.js +7 -3
- package/lib/ReactElement.js +72 -35
- package/lib/ReactElementValidator.js +31 -75
- package/lib/ReactEmptyComponent.js +25 -61
- package/lib/ReactEmptyComponentRegistry.js +48 -0
- package/lib/ReactErrorUtils.js +55 -9
- package/lib/ReactEventEmitterMixin.js +1 -1
- package/lib/ReactEventListener.js +16 -9
- package/lib/ReactFragment.js +25 -116
- package/lib/ReactInjection.js +0 -2
- package/lib/ReactIsomorphic.js +4 -0
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMount.js +127 -41
- package/lib/ReactMultiChild.js +37 -4
- package/lib/ReactOwner.js +2 -2
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypes.js +11 -8
- package/lib/ReactReconcileTransaction.js +4 -2
- package/lib/ReactReconciler.js +16 -17
- package/lib/ReactRef.js +13 -1
- package/lib/ReactServerRenderingTransaction.js +1 -0
- package/lib/ReactTestUtils.js +27 -15
- package/lib/ReactTransitionChildMapping.js +3 -6
- package/lib/ReactUpdateQueue.js +4 -4
- package/lib/ReactUpdates.js +1 -1
- package/lib/ReactVersion.js +14 -0
- package/lib/ReactWithAddons.js +10 -1
- package/lib/ResponderEventPlugin.js +1 -1
- package/lib/SelectEventPlugin.js +11 -1
- package/lib/SimpleEventPlugin.js +10 -31
- package/lib/SyntheticEvent.js +15 -1
- package/lib/Transaction.js +1 -1
- package/lib/canDefineProperty.js +24 -0
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/deprecated.js +3 -2
- package/lib/findDOMNode.js +1 -1
- package/lib/getTestDocument.js +4 -11
- package/lib/instantiateReactComponent.js +3 -5
- package/lib/reactComponentExpect.js +6 -0
- package/lib/shouldUpdateReactComponent.js +12 -8
- package/lib/sliceChildren.js +3 -20
- package/lib/traverseAllChildren.js +15 -9
- package/package.json +2 -2
- package/react.js +1 -51
- package/dist/JSXTransformer.js +0 -17949
- package/lib/joinClasses.js +0 -39
- package/lib/memoizeStringOnly.js +0 -31
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
21
|
var ReactElement = require('./ReactElement');
|
|
22
|
-
var ReactFragment = require('./ReactFragment');
|
|
23
22
|
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
24
23
|
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
25
24
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
26
25
|
|
|
26
|
+
var canDefineProperty = require('./canDefineProperty');
|
|
27
27
|
var getIteratorFn = require('./getIteratorFn');
|
|
28
28
|
var invariant = require('fbjs/lib/invariant');
|
|
29
29
|
var warning = require('fbjs/lib/warning');
|
|
@@ -47,37 +47,6 @@ var ownerHasKeyUseWarning = {};
|
|
|
47
47
|
|
|
48
48
|
var loggedTypeFailures = {};
|
|
49
49
|
|
|
50
|
-
var NUMERIC_PROPERTY_REGEX = /^\d+$/;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Gets the instance's name for use in warnings.
|
|
54
|
-
*
|
|
55
|
-
* @internal
|
|
56
|
-
* @return {?string} Display name or undefined
|
|
57
|
-
*/
|
|
58
|
-
function getName(instance) {
|
|
59
|
-
var publicInstance = instance && instance.getPublicInstance();
|
|
60
|
-
if (!publicInstance) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
var constructor = publicInstance.constructor;
|
|
64
|
-
if (!constructor) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
return constructor.displayName || constructor.name || undefined;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Gets the current owner's displayName for use in warnings.
|
|
72
|
-
*
|
|
73
|
-
* @internal
|
|
74
|
-
* @return {?string} Display name or undefined
|
|
75
|
-
*/
|
|
76
|
-
function getCurrentOwnerDisplayName() {
|
|
77
|
-
var current = ReactCurrentOwner.current;
|
|
78
|
-
return current && getName(current) || undefined;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
50
|
/**
|
|
82
51
|
* Warn if the element doesn't have an explicit key assigned to it.
|
|
83
52
|
* This element is in an array. The array could grow and shrink or be
|
|
@@ -89,7 +58,7 @@ function getCurrentOwnerDisplayName() {
|
|
|
89
58
|
* @param {*} parentType element's parent's type.
|
|
90
59
|
*/
|
|
91
60
|
function validateExplicitKey(element, parentType) {
|
|
92
|
-
if (element._store.validated || element.key != null) {
|
|
61
|
+
if (!element._store || element._store.validated || element.key != null) {
|
|
93
62
|
return;
|
|
94
63
|
}
|
|
95
64
|
element._store.validated = true;
|
|
@@ -102,27 +71,6 @@ function validateExplicitKey(element, parentType) {
|
|
|
102
71
|
process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
|
|
103
72
|
}
|
|
104
73
|
|
|
105
|
-
/**
|
|
106
|
-
* Warn if the key is being defined as an object property but has an incorrect
|
|
107
|
-
* value.
|
|
108
|
-
*
|
|
109
|
-
* @internal
|
|
110
|
-
* @param {string} name Property name of the key.
|
|
111
|
-
* @param {ReactElement} element Component that requires a key.
|
|
112
|
-
* @param {*} parentType element's parent's type.
|
|
113
|
-
*/
|
|
114
|
-
function validatePropertyKey(name, element, parentType) {
|
|
115
|
-
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
var addenda = getAddendaForKeyUse('numericKeys', element, parentType);
|
|
119
|
-
if (addenda === null) {
|
|
120
|
-
// we already showed the warning
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Child objects should have non-numeric keys so ordering is preserved.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
74
|
/**
|
|
127
75
|
* Shared warning and monitoring code for the key warnings.
|
|
128
76
|
*
|
|
@@ -134,18 +82,22 @@ function validatePropertyKey(name, element, parentType) {
|
|
|
134
82
|
* if the warning has already been shown before (and shouldn't be shown again).
|
|
135
83
|
*/
|
|
136
84
|
function getAddendaForKeyUse(messageType, element, parentType) {
|
|
137
|
-
var
|
|
138
|
-
|
|
85
|
+
var addendum = getDeclarationErrorAddendum();
|
|
86
|
+
if (!addendum) {
|
|
87
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
88
|
+
if (parentName) {
|
|
89
|
+
addendum = ' Check the top-level render call using <' + parentName + '>.';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
139
92
|
|
|
140
|
-
var useName = ownerName || parentName;
|
|
141
93
|
var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
|
|
142
|
-
if (memoizer[
|
|
94
|
+
if (memoizer[addendum]) {
|
|
143
95
|
return null;
|
|
144
96
|
}
|
|
145
|
-
memoizer[
|
|
97
|
+
memoizer[addendum] = true;
|
|
146
98
|
|
|
147
99
|
var addenda = {
|
|
148
|
-
parentOrOwner:
|
|
100
|
+
parentOrOwner: addendum,
|
|
149
101
|
url: ' See https://fb.me/react-warning-keys for more information.',
|
|
150
102
|
childOwner: null
|
|
151
103
|
};
|
|
@@ -155,7 +107,7 @@ function getAddendaForKeyUse(messageType, element, parentType) {
|
|
|
155
107
|
// assigning it a key.
|
|
156
108
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
157
109
|
// Give the component that originally created this child.
|
|
158
|
-
addenda.childOwner = ' It was passed a child from ' +
|
|
110
|
+
addenda.childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
|
|
159
111
|
}
|
|
160
112
|
|
|
161
113
|
return addenda;
|
|
@@ -171,6 +123,9 @@ function getAddendaForKeyUse(messageType, element, parentType) {
|
|
|
171
123
|
* @param {*} parentType node's parent's type.
|
|
172
124
|
*/
|
|
173
125
|
function validateChildKeys(node, parentType) {
|
|
126
|
+
if (typeof node !== 'object') {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
174
129
|
if (Array.isArray(node)) {
|
|
175
130
|
for (var i = 0; i < node.length; i++) {
|
|
176
131
|
var child = node[i];
|
|
@@ -180,7 +135,9 @@ function validateChildKeys(node, parentType) {
|
|
|
180
135
|
}
|
|
181
136
|
} else if (ReactElement.isValidElement(node)) {
|
|
182
137
|
// This element was passed in a valid location.
|
|
183
|
-
node._store
|
|
138
|
+
if (node._store) {
|
|
139
|
+
node._store.validated = true;
|
|
140
|
+
}
|
|
184
141
|
} else if (node) {
|
|
185
142
|
var iteratorFn = getIteratorFn(node);
|
|
186
143
|
// Entry iterators provide implicit keys.
|
|
@@ -194,13 +151,6 @@ function validateChildKeys(node, parentType) {
|
|
|
194
151
|
}
|
|
195
152
|
}
|
|
196
153
|
}
|
|
197
|
-
} else if (typeof node === 'object') {
|
|
198
|
-
var fragment = ReactFragment.extractIfFragment(node);
|
|
199
|
-
for (var key in fragment) {
|
|
200
|
-
if (fragment.hasOwnProperty(key)) {
|
|
201
|
-
validatePropertyKey(key, fragment[key], parentType);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
154
|
}
|
|
205
155
|
}
|
|
206
156
|
}
|
|
@@ -265,9 +215,10 @@ function validatePropTypes(element) {
|
|
|
265
215
|
var ReactElementValidator = {
|
|
266
216
|
|
|
267
217
|
createElement: function (type, props, children) {
|
|
218
|
+
var validType = typeof type === 'string' || typeof type === 'function';
|
|
268
219
|
// We warn in this case but don't throw. We expect the element creation to
|
|
269
220
|
// succeed and there will likely be errors in render.
|
|
270
|
-
process.env.NODE_ENV !== 'production' ? warning(
|
|
221
|
+
process.env.NODE_ENV !== 'production' ? warning(validType, 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : undefined;
|
|
271
222
|
|
|
272
223
|
var element = ReactElement.createElement.apply(this, arguments);
|
|
273
224
|
|
|
@@ -277,8 +228,15 @@ var ReactElementValidator = {
|
|
|
277
228
|
return element;
|
|
278
229
|
}
|
|
279
230
|
|
|
280
|
-
|
|
281
|
-
|
|
231
|
+
// Skip key warning if the type isn't valid since our key validation logic
|
|
232
|
+
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
233
|
+
// We don't want exception behavior to differ between dev and prod.
|
|
234
|
+
// (Rendering will throw with a helpful message and as soon as the type is
|
|
235
|
+
// fixed, the key warnings will appear.)
|
|
236
|
+
if (validType) {
|
|
237
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
238
|
+
validateChildKeys(arguments[i], type);
|
|
239
|
+
}
|
|
282
240
|
}
|
|
283
241
|
|
|
284
242
|
validatePropTypes(element);
|
|
@@ -292,7 +250,7 @@ var ReactElementValidator = {
|
|
|
292
250
|
validatedFactory.type = type;
|
|
293
251
|
|
|
294
252
|
if (process.env.NODE_ENV !== 'production') {
|
|
295
|
-
|
|
253
|
+
if (canDefineProperty) {
|
|
296
254
|
Object.defineProperty(validatedFactory, 'type', {
|
|
297
255
|
enumerable: false,
|
|
298
256
|
get: function () {
|
|
@@ -303,8 +261,6 @@ var ReactElementValidator = {
|
|
|
303
261
|
return type;
|
|
304
262
|
}
|
|
305
263
|
});
|
|
306
|
-
} catch (x) {
|
|
307
|
-
// IE will fail on defineProperty (es5-shim/sham too)
|
|
308
264
|
}
|
|
309
265
|
}
|
|
310
266
|
|
|
@@ -12,76 +12,40 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactElement = require('./ReactElement');
|
|
15
|
-
var
|
|
15
|
+
var ReactEmptyComponentRegistry = require('./ReactEmptyComponentRegistry');
|
|
16
|
+
var ReactReconciler = require('./ReactReconciler');
|
|
16
17
|
|
|
17
|
-
var
|
|
18
|
+
var assign = require('./Object.assign');
|
|
18
19
|
|
|
19
|
-
var
|
|
20
|
-
// This registry keeps track of the React IDs of the components that rendered to
|
|
21
|
-
// `null` (in reality a placeholder such as `noscript`)
|
|
22
|
-
var nullComponentIDsRegistry = {};
|
|
20
|
+
var placeholderElement;
|
|
23
21
|
|
|
24
22
|
var ReactEmptyComponentInjection = {
|
|
25
|
-
injectEmptyComponent: function (
|
|
26
|
-
|
|
23
|
+
injectEmptyComponent: function (component) {
|
|
24
|
+
placeholderElement = ReactElement.createElement(component);
|
|
27
25
|
}
|
|
28
26
|
};
|
|
29
27
|
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// need this check. We're going to assume if we're here it means we ran
|
|
35
|
-
// componentWillUnmount already so there is no internal instance (it gets
|
|
36
|
-
// removed as part of the unmounting process).
|
|
37
|
-
if (!internalInstance) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
registerNullComponentID(internalInstance._rootNodeID);
|
|
28
|
+
var ReactEmptyComponent = function (instantiate) {
|
|
29
|
+
this._currentElement = null;
|
|
30
|
+
this._rootNodeID = null;
|
|
31
|
+
this._renderedComponent = instantiate(placeholderElement);
|
|
41
32
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
assign(ReactEmptyComponent.prototype, {
|
|
34
|
+
construct: function (element) {},
|
|
35
|
+
mountComponent: function (rootID, transaction, context) {
|
|
36
|
+
ReactEmptyComponentRegistry.registerNullComponentID(rootID);
|
|
37
|
+
this._rootNodeID = rootID;
|
|
38
|
+
return ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, context);
|
|
39
|
+
},
|
|
40
|
+
receiveComponent: function () {},
|
|
41
|
+
unmountComponent: function (rootID, transaction, context) {
|
|
42
|
+
ReactReconciler.unmountComponent(this._renderedComponent);
|
|
43
|
+
ReactEmptyComponentRegistry.deregisterNullComponentID(this._rootNodeID);
|
|
44
|
+
this._rootNodeID = null;
|
|
45
|
+
this._renderedComponent = null;
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
ReactEmptyComponentType.prototype.render = function () {
|
|
51
|
-
!component ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to return null from a render, but no null placeholder component ' + 'was injected.') : invariant(false) : undefined;
|
|
52
|
-
return component();
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
var emptyElement = ReactElement.createElement(ReactEmptyComponentType);
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Mark the component as having rendered to null.
|
|
59
|
-
* @param {string} id Component's `_rootNodeID`.
|
|
60
|
-
*/
|
|
61
|
-
function registerNullComponentID(id) {
|
|
62
|
-
nullComponentIDsRegistry[id] = true;
|
|
63
|
-
}
|
|
47
|
+
});
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
* Unmark the component as having rendered to null: it renders to something now.
|
|
67
|
-
* @param {string} id Component's `_rootNodeID`.
|
|
68
|
-
*/
|
|
69
|
-
function deregisterNullComponentID(id) {
|
|
70
|
-
delete nullComponentIDsRegistry[id];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @param {string} id Component's `_rootNodeID`.
|
|
75
|
-
* @return {boolean} True if the component is rendered to null.
|
|
76
|
-
*/
|
|
77
|
-
function isNullComponentID(id) {
|
|
78
|
-
return !!nullComponentIDsRegistry[id];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
var ReactEmptyComponent = {
|
|
82
|
-
emptyElement: emptyElement,
|
|
83
|
-
injection: ReactEmptyComponentInjection,
|
|
84
|
-
isNullComponentID: isNullComponentID
|
|
85
|
-
};
|
|
49
|
+
ReactEmptyComponent.injection = ReactEmptyComponentInjection;
|
|
86
50
|
|
|
87
51
|
module.exports = ReactEmptyComponent;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2014-2015, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactEmptyComponentRegistry
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
// This registry keeps track of the React IDs of the components that rendered to
|
|
15
|
+
// `null` (in reality a placeholder such as `noscript`)
|
|
16
|
+
var nullComponentIDsRegistry = {};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} id Component's `_rootNodeID`.
|
|
20
|
+
* @return {boolean} True if the component is rendered to null.
|
|
21
|
+
*/
|
|
22
|
+
function isNullComponentID(id) {
|
|
23
|
+
return !!nullComponentIDsRegistry[id];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Mark the component as having rendered to null.
|
|
28
|
+
* @param {string} id Component's `_rootNodeID`.
|
|
29
|
+
*/
|
|
30
|
+
function registerNullComponentID(id) {
|
|
31
|
+
nullComponentIDsRegistry[id] = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Unmark the component as having rendered to null: it renders to something now.
|
|
36
|
+
* @param {string} id Component's `_rootNodeID`.
|
|
37
|
+
*/
|
|
38
|
+
function deregisterNullComponentID(id) {
|
|
39
|
+
delete nullComponentIDsRegistry[id];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var ReactEmptyComponentRegistry = {
|
|
43
|
+
isNullComponentID: isNullComponentID,
|
|
44
|
+
registerNullComponentID: registerNullComponentID,
|
|
45
|
+
deregisterNullComponentID: deregisterNullComponentID
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
module.exports = ReactEmptyComponentRegistry;
|
package/lib/ReactErrorUtils.js
CHANGED
|
@@ -12,19 +12,65 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
+
var caughtError = null;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Call a function while guarding against errors that happens within it.
|
|
19
|
+
*
|
|
20
|
+
* @param {?String} name of the guard to use for logging or debugging
|
|
21
|
+
* @param {Function} func The function to invoke
|
|
22
|
+
* @param {*} a First argument
|
|
23
|
+
* @param {*} b Second argument
|
|
24
|
+
*/
|
|
25
|
+
function invokeGuardedCallback(name, func, a, b) {
|
|
26
|
+
try {
|
|
27
|
+
return func(a, b);
|
|
28
|
+
} catch (x) {
|
|
29
|
+
if (caughtError === null) {
|
|
30
|
+
caughtError = x;
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
15
36
|
var ReactErrorUtils = {
|
|
37
|
+
invokeGuardedCallback: invokeGuardedCallback,
|
|
38
|
+
|
|
16
39
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* this currently simply returns the original function.
|
|
20
|
-
*
|
|
21
|
-
* @param {function} func Function to be executed
|
|
22
|
-
* @param {string} name The name of the guard
|
|
23
|
-
* @return {function}
|
|
40
|
+
* Invoked by ReactTestUtils.Simulate so that any errors thrown by the event
|
|
41
|
+
* handler are sure to be rethrown by rethrowCaughtError.
|
|
24
42
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
invokeGuardedCallbackWithCatch: invokeGuardedCallback,
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* During execution of guarded functions we will capture the first error which
|
|
47
|
+
* we will rethrow to be handled by the top level error handler.
|
|
48
|
+
*/
|
|
49
|
+
rethrowCaughtError: function () {
|
|
50
|
+
if (caughtError) {
|
|
51
|
+
var error = caughtError;
|
|
52
|
+
caughtError = null;
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
27
55
|
}
|
|
28
56
|
};
|
|
29
57
|
|
|
58
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
59
|
+
/**
|
|
60
|
+
* To help development we can get better devtools integration by simulating a
|
|
61
|
+
* real browser event.
|
|
62
|
+
*/
|
|
63
|
+
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
|
64
|
+
var fakeNode = document.createElement('react');
|
|
65
|
+
ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) {
|
|
66
|
+
var boundFunc = func.bind(null, a, b);
|
|
67
|
+
fakeNode.addEventListener(name, boundFunc, false);
|
|
68
|
+
var evt = document.createEvent('Event');
|
|
69
|
+
evt.initEvent(name, false, false);
|
|
70
|
+
fakeNode.dispatchEvent(evt);
|
|
71
|
+
fakeNode.removeEventListener(name, boundFunc, false);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
30
76
|
module.exports = ReactErrorUtils;
|
|
@@ -15,7 +15,7 @@ var EventPluginHub = require('./EventPluginHub');
|
|
|
15
15
|
|
|
16
16
|
function runEventQueueInBatch(events) {
|
|
17
17
|
EventPluginHub.enqueueEvents(events);
|
|
18
|
-
EventPluginHub.processEventQueue();
|
|
18
|
+
EventPluginHub.processEventQueue(false);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
var ReactEventEmitterMixin = {
|
|
@@ -59,13 +59,18 @@ assign(TopLevelCallbackBookKeeping.prototype, {
|
|
|
59
59
|
PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
|
|
60
60
|
|
|
61
61
|
function handleTopLevelImpl(bookKeeping) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
// TODO: Re-enable event.path handling
|
|
63
|
+
//
|
|
64
|
+
// if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) {
|
|
65
|
+
// // New browsers have a path attribute on native events
|
|
66
|
+
// handleTopLevelWithPath(bookKeeping);
|
|
67
|
+
// } else {
|
|
68
|
+
// // Legacy browsers don't have a path attribute on native events
|
|
69
|
+
// handleTopLevelWithoutPath(bookKeeping);
|
|
70
|
+
// }
|
|
71
|
+
|
|
72
|
+
void handleTopLevelWithPath; // temporarily unused
|
|
73
|
+
handleTopLevelWithoutPath(bookKeeping);
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
// Legacy browsers don't have a path attribute on native events
|
|
@@ -96,11 +101,13 @@ function handleTopLevelWithPath(bookKeeping) {
|
|
|
96
101
|
var eventsFired = 0;
|
|
97
102
|
for (var i = 0; i < path.length; i++) {
|
|
98
103
|
var currentPathElement = path[i];
|
|
99
|
-
var currentPathElementID = ReactMount.getID(currentPathElement);
|
|
100
104
|
if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
|
|
101
105
|
currentNativeTarget = path[i + 1];
|
|
102
106
|
}
|
|
103
|
-
|
|
107
|
+
// TODO: slow
|
|
108
|
+
var reactParent = ReactMount.getFirstReactDOM(currentPathElement);
|
|
109
|
+
if (reactParent === currentPathElement) {
|
|
110
|
+
var currentPathElementID = ReactMount.getID(currentPathElement);
|
|
104
111
|
var newRootID = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElementID);
|
|
105
112
|
bookKeeping.ancestors.push(currentPathElement);
|
|
106
113
|
|