react 0.13.2 → 0.14.0-alpha3
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 +1 -1
- package/addons.js +7 -0
- package/addons/CSSTransitionGroup.js +1 -0
- package/addons/LinkedStateMixin.js +1 -0
- package/addons/Perf.js +1 -0
- package/addons/PureRenderMixin.js +1 -0
- package/addons/TestUtils.js +1 -0
- package/addons/TransitionGroup.js +1 -0
- package/addons/batchedUpdates.js +1 -0
- package/addons/cloneWithProps.js +1 -0
- package/addons/createFragment.js +1 -0
- package/addons/renderSubtreeIntoContainer.js +1 -0
- package/addons/shallowCompare.js +1 -0
- package/addons/update.js +1 -0
- package/dist/JSXTransformer.js +3355 -1685
- package/dist/react-with-addons.js +3320 -5133
- package/dist/react-with-addons.min.js +6 -7
- package/dist/react.js +2962 -4548
- package/dist/react.min.js +5 -5
- package/lib/AutoFocusMixin.js +4 -3
- package/lib/BeforeInputEventPlugin.js +30 -118
- package/lib/CSSCore.js +12 -23
- package/lib/CSSProperty.js +4 -3
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +24 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +41 -67
- package/lib/DOMPropertyOperations.js +30 -51
- package/lib/Danger.js +19 -62
- package/lib/DefaultEventPluginOrder.js +2 -12
- package/lib/EnterLeaveEventPlugin.js +11 -33
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +11 -13
- package/lib/EventPluginHub.js +44 -47
- package/lib/EventPluginRegistry.js +18 -74
- package/lib/EventPluginUtils.js +27 -38
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +7 -19
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +34 -64
- package/lib/LocalEventTrapMixin.js +9 -16
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +8 -11
- package/lib/React.js +9 -129
- package/lib/ReactBrowserComponentMixin.js +9 -2
- package/lib/ReactBrowserEventEmitter.js +26 -82
- package/lib/ReactCSSTransitionGroup.js +13 -24
- package/lib/ReactCSSTransitionGroupChild.js +18 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +21 -28
- package/lib/ReactClass.js +81 -234
- package/lib/ReactComponent.js +17 -33
- package/lib/ReactComponentBrowserEnvironment.js +4 -8
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +4 -5
- package/lib/ReactCompositeComponent.js +87 -311
- package/lib/ReactContext.js +2 -44
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +4 -2
- package/lib/ReactDOMButton.js +3 -4
- package/lib/ReactDOMClient.js +85 -0
- package/lib/ReactDOMComponent.js +182 -146
- package/lib/ReactDOMForm.js +3 -3
- package/lib/ReactDOMIDOperations.js +11 -22
- package/lib/ReactDOMIframe.js +3 -3
- package/lib/ReactDOMImg.js +3 -3
- package/lib/ReactDOMInput.js +22 -35
- package/lib/ReactDOMOption.js +67 -10
- package/lib/ReactDOMSelect.js +50 -28
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +15 -27
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +31 -40
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +24 -57
- package/lib/ReactElementValidator.js +38 -105
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +2 -2
- package/lib/ReactEventEmitterMixin.js +3 -12
- package/lib/ReactEventListener.js +16 -38
- package/lib/ReactFragment.js +23 -54
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +11 -21
- package/lib/ReactInstanceHandles.js +27 -57
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLifeCycle.js +1 -1
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +137 -260
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +7 -11
- package/lib/ReactOwner.js +7 -24
- package/lib/ReactPerf.js +8 -12
- package/lib/ReactPropTransferer.js +4 -4
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +41 -61
- package/lib/ReactReconcileTransaction.js +9 -34
- package/lib/ReactReconciler.js +9 -19
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +7 -15
- package/lib/ReactServerRenderingTransaction.js +7 -32
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +93 -165
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +27 -90
- package/lib/ReactUpdates.js +27 -79
- package/lib/ReactWithAddons.js +7 -6
- package/lib/SVGDOMPropertyConfig.js +41 -4
- package/lib/SelectEventPlugin.js +28 -29
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +136 -128
- package/lib/SyntheticClipboardEvent.js +3 -7
- package/lib/SyntheticCompositionEvent.js +3 -9
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +8 -10
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +3 -9
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +8 -14
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +3 -3
- package/lib/SyntheticWheelEvent.js +11 -15
- package/lib/Transaction.js +12 -24
- package/lib/ViewportMetrics.js +2 -2
- package/lib/accumulateInto.js +2 -5
- package/lib/adler32.js +2 -4
- package/lib/camelize.js +4 -2
- package/lib/camelizeStyleName.js +2 -2
- package/lib/cloneWithProps.js +5 -11
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createFullPageComponent.js +4 -11
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +5 -24
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +2 -2
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -1
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +7 -5
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getTextContentAccessor.js +2 -4
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +3 -1
- package/lib/hyphenateStyleName.js +2 -2
- package/lib/instantiateReactComponent.js +14 -38
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +2 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +2 -2
- package/lib/keyMirror.js +3 -6
- package/lib/keyOf.js +4 -3
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +2 -2
- package/lib/onlyChild.js +2 -5
- package/lib/performance.js +2 -5
- package/lib/performanceNow.js +3 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +16 -0
- package/lib/setInnerHTML.js +11 -8
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +24 -0
- package/lib/shallowEqual.js +17 -11
- package/lib/shouldUpdateReactComponent.js +3 -64
- package/lib/toArray.js +8 -19
- package/lib/traverseAllChildren.js +22 -89
- package/lib/update.js +25 -85
- package/lib/validateDOMNesting.js +363 -0
- package/lib/warning.js +17 -15
- package/package.json +3 -3
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
package/lib/ReactMultiChild.js
CHANGED
|
@@ -134,10 +134,7 @@ function enqueueTextContent(parentID, textContent) {
|
|
|
134
134
|
*/
|
|
135
135
|
function processQueue() {
|
|
136
136
|
if (updateQueue.length) {
|
|
137
|
-
ReactComponentEnvironment.processChildrenUpdates(
|
|
138
|
-
updateQueue,
|
|
139
|
-
markupQueue
|
|
140
|
-
);
|
|
137
|
+
ReactComponentEnvironment.processChildrenUpdates(updateQueue, markupQueue);
|
|
141
138
|
clearQueue();
|
|
142
139
|
}
|
|
143
140
|
}
|
|
@@ -177,10 +174,8 @@ var ReactMultiChild = {
|
|
|
177
174
|
* @return {array} An array of mounted representations.
|
|
178
175
|
* @internal
|
|
179
176
|
*/
|
|
180
|
-
mountChildren: function(nestedChildren, transaction, context) {
|
|
181
|
-
var children = ReactChildReconciler.instantiateChildren(
|
|
182
|
-
nestedChildren, transaction, context
|
|
183
|
-
);
|
|
177
|
+
mountChildren: function (nestedChildren, transaction, context) {
|
|
178
|
+
var children = ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
|
|
184
179
|
this._renderedChildren = children;
|
|
185
180
|
var mountImages = [];
|
|
186
181
|
var index = 0;
|
|
@@ -189,12 +184,7 @@ var ReactMultiChild = {
|
|
|
189
184
|
var child = children[name];
|
|
190
185
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
191
186
|
var rootID = this._rootNodeID + name;
|
|
192
|
-
var mountImage = ReactReconciler.mountComponent(
|
|
193
|
-
child,
|
|
194
|
-
rootID,
|
|
195
|
-
transaction,
|
|
196
|
-
context
|
|
197
|
-
);
|
|
187
|
+
var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
|
|
198
188
|
child._mountIndex = index;
|
|
199
189
|
mountImages.push(mountImage);
|
|
200
190
|
index++;
|
|
@@ -209,7 +199,7 @@ var ReactMultiChild = {
|
|
|
209
199
|
* @param {string} nextContent String of content.
|
|
210
200
|
* @internal
|
|
211
201
|
*/
|
|
212
|
-
updateTextContent: function(nextContent) {
|
|
202
|
+
updateTextContent: function (nextContent) {
|
|
213
203
|
updateDepth++;
|
|
214
204
|
var errorThrown = true;
|
|
215
205
|
try {
|
|
@@ -244,7 +234,7 @@ var ReactMultiChild = {
|
|
|
244
234
|
* @param {ReactReconcileTransaction} transaction
|
|
245
235
|
* @internal
|
|
246
236
|
*/
|
|
247
|
-
updateChildren: function(nextNestedChildren, transaction, context) {
|
|
237
|
+
updateChildren: function (nextNestedChildren, transaction, context) {
|
|
248
238
|
updateDepth++;
|
|
249
239
|
var errorThrown = true;
|
|
250
240
|
try {
|
|
@@ -259,7 +249,6 @@ var ReactMultiChild = {
|
|
|
259
249
|
processQueue();
|
|
260
250
|
}
|
|
261
251
|
}
|
|
262
|
-
|
|
263
252
|
}
|
|
264
253
|
},
|
|
265
254
|
|
|
@@ -272,11 +261,9 @@ var ReactMultiChild = {
|
|
|
272
261
|
* @final
|
|
273
262
|
* @protected
|
|
274
263
|
*/
|
|
275
|
-
_updateChildren: function(nextNestedChildren, transaction, context) {
|
|
264
|
+
_updateChildren: function (nextNestedChildren, transaction, context) {
|
|
276
265
|
var prevChildren = this._renderedChildren;
|
|
277
|
-
var nextChildren = ReactChildReconciler.updateChildren(
|
|
278
|
-
prevChildren, nextNestedChildren, transaction, context
|
|
279
|
-
);
|
|
266
|
+
var nextChildren = ReactChildReconciler.updateChildren(prevChildren, nextNestedChildren, transaction, context);
|
|
280
267
|
this._renderedChildren = nextChildren;
|
|
281
268
|
if (!nextChildren && !prevChildren) {
|
|
282
269
|
return;
|
|
@@ -303,16 +290,13 @@ var ReactMultiChild = {
|
|
|
303
290
|
this._unmountChildByName(prevChild, name);
|
|
304
291
|
}
|
|
305
292
|
// The child must be instantiated before it's mounted.
|
|
306
|
-
this._mountChildByNameAtIndex(
|
|
307
|
-
nextChild, name, nextIndex, transaction, context
|
|
308
|
-
);
|
|
293
|
+
this._mountChildByNameAtIndex(nextChild, name, nextIndex, transaction, context);
|
|
309
294
|
}
|
|
310
295
|
nextIndex++;
|
|
311
296
|
}
|
|
312
297
|
// Remove children that are no longer present.
|
|
313
298
|
for (name in prevChildren) {
|
|
314
|
-
if (prevChildren.hasOwnProperty(name) &&
|
|
315
|
-
!(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
299
|
+
if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
316
300
|
this._unmountChildByName(prevChildren[name], name);
|
|
317
301
|
}
|
|
318
302
|
}
|
|
@@ -324,7 +308,7 @@ var ReactMultiChild = {
|
|
|
324
308
|
*
|
|
325
309
|
* @internal
|
|
326
310
|
*/
|
|
327
|
-
unmountChildren: function() {
|
|
311
|
+
unmountChildren: function () {
|
|
328
312
|
var renderedChildren = this._renderedChildren;
|
|
329
313
|
ReactChildReconciler.unmountChildren(renderedChildren);
|
|
330
314
|
this._renderedChildren = null;
|
|
@@ -338,7 +322,7 @@ var ReactMultiChild = {
|
|
|
338
322
|
* @param {number} lastIndex Last index visited of the siblings of `child`.
|
|
339
323
|
* @protected
|
|
340
324
|
*/
|
|
341
|
-
moveChild: function(child, toIndex, lastIndex) {
|
|
325
|
+
moveChild: function (child, toIndex, lastIndex) {
|
|
342
326
|
// If the index of `child` is less than `lastIndex`, then it needs to
|
|
343
327
|
// be moved. Otherwise, we do not need to move it because a child will be
|
|
344
328
|
// inserted or moved before `child`.
|
|
@@ -354,7 +338,7 @@ var ReactMultiChild = {
|
|
|
354
338
|
* @param {string} mountImage Markup to insert.
|
|
355
339
|
* @protected
|
|
356
340
|
*/
|
|
357
|
-
createChild: function(child, mountImage) {
|
|
341
|
+
createChild: function (child, mountImage) {
|
|
358
342
|
enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
|
|
359
343
|
},
|
|
360
344
|
|
|
@@ -364,7 +348,7 @@ var ReactMultiChild = {
|
|
|
364
348
|
* @param {ReactComponent} child Child to remove.
|
|
365
349
|
* @protected
|
|
366
350
|
*/
|
|
367
|
-
removeChild: function(child) {
|
|
351
|
+
removeChild: function (child) {
|
|
368
352
|
enqueueRemove(this._rootNodeID, child._mountIndex);
|
|
369
353
|
},
|
|
370
354
|
|
|
@@ -374,7 +358,7 @@ var ReactMultiChild = {
|
|
|
374
358
|
* @param {string} textContent Text content to set.
|
|
375
359
|
* @protected
|
|
376
360
|
*/
|
|
377
|
-
setTextContent: function(textContent) {
|
|
361
|
+
setTextContent: function (textContent) {
|
|
378
362
|
enqueueTextContent(this._rootNodeID, textContent);
|
|
379
363
|
},
|
|
380
364
|
|
|
@@ -389,20 +373,10 @@ var ReactMultiChild = {
|
|
|
389
373
|
* @param {ReactReconcileTransaction} transaction
|
|
390
374
|
* @private
|
|
391
375
|
*/
|
|
392
|
-
_mountChildByNameAtIndex: function(
|
|
393
|
-
child,
|
|
394
|
-
name,
|
|
395
|
-
index,
|
|
396
|
-
transaction,
|
|
397
|
-
context) {
|
|
376
|
+
_mountChildByNameAtIndex: function (child, name, index, transaction, context) {
|
|
398
377
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
399
378
|
var rootID = this._rootNodeID + name;
|
|
400
|
-
var mountImage = ReactReconciler.mountComponent(
|
|
401
|
-
child,
|
|
402
|
-
rootID,
|
|
403
|
-
transaction,
|
|
404
|
-
context
|
|
405
|
-
);
|
|
379
|
+
var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
|
|
406
380
|
child._mountIndex = index;
|
|
407
381
|
this.createChild(child, mountImage);
|
|
408
382
|
},
|
|
@@ -416,7 +390,7 @@ var ReactMultiChild = {
|
|
|
416
390
|
* @param {string} name Name of the child in `this._renderedChildren`.
|
|
417
391
|
* @private
|
|
418
392
|
*/
|
|
419
|
-
_unmountChildByName: function(child, name) {
|
|
393
|
+
_unmountChildByName: function (child, name) {
|
|
420
394
|
this.removeChild(child);
|
|
421
395
|
child._mountIndex = null;
|
|
422
396
|
}
|
|
@@ -425,4 +399,4 @@ var ReactMultiChild = {
|
|
|
425
399
|
|
|
426
400
|
};
|
|
427
401
|
|
|
428
|
-
module.exports = ReactMultiChild;
|
|
402
|
+
module.exports = ReactMultiChild;
|
|
@@ -16,29 +16,29 @@ var invariant = require("./invariant");
|
|
|
16
16
|
|
|
17
17
|
var autoGenerateWrapperClass = null;
|
|
18
18
|
var genericComponentClass = null;
|
|
19
|
-
// This registry keeps track of wrapper classes around native tags
|
|
19
|
+
// This registry keeps track of wrapper classes around native tags.
|
|
20
20
|
var tagToComponentClass = {};
|
|
21
21
|
var textComponentClass = null;
|
|
22
22
|
|
|
23
23
|
var ReactNativeComponentInjection = {
|
|
24
24
|
// This accepts a class that receives the tag string. This is a catch all
|
|
25
25
|
// that can render any kind of tag.
|
|
26
|
-
injectGenericComponentClass: function(componentClass) {
|
|
26
|
+
injectGenericComponentClass: function (componentClass) {
|
|
27
27
|
genericComponentClass = componentClass;
|
|
28
28
|
},
|
|
29
29
|
// This accepts a text component class that takes the text string to be
|
|
30
30
|
// rendered as props.
|
|
31
|
-
injectTextComponentClass: function(componentClass) {
|
|
31
|
+
injectTextComponentClass: function (componentClass) {
|
|
32
32
|
textComponentClass = componentClass;
|
|
33
33
|
},
|
|
34
34
|
// This accepts a keyed object with classes as values. Each key represents a
|
|
35
35
|
// tag. That particular tag will use this class instead of the generic one.
|
|
36
|
-
injectComponentClasses: function(componentClasses) {
|
|
36
|
+
injectComponentClasses: function (componentClasses) {
|
|
37
37
|
assign(tagToComponentClass, componentClasses);
|
|
38
38
|
},
|
|
39
39
|
// Temporary hack since we expect DOM refs to behave like composites,
|
|
40
40
|
// for this release.
|
|
41
|
-
injectAutoWrapper: function(wrapperFactory) {
|
|
41
|
+
injectAutoWrapper: function (wrapperFactory) {
|
|
42
42
|
autoGenerateWrapperClass = wrapperFactory;
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -68,11 +68,7 @@ function getComponentClassForElement(element) {
|
|
|
68
68
|
* @return {function} The internal class constructor function.
|
|
69
69
|
*/
|
|
70
70
|
function createInternalComponent(element) {
|
|
71
|
-
|
|
72
|
-
genericComponentClass,
|
|
73
|
-
'There is no registered component for the tag %s',
|
|
74
|
-
element.type
|
|
75
|
-
) : invariant(genericComponentClass));
|
|
71
|
+
!genericComponentClass ? 'production' !== process.env.NODE_ENV ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : undefined;
|
|
76
72
|
return new genericComponentClass(element.type, element.props);
|
|
77
73
|
}
|
|
78
74
|
|
|
@@ -100,4 +96,4 @@ var ReactNativeComponent = {
|
|
|
100
96
|
injection: ReactNativeComponentInjection
|
|
101
97
|
};
|
|
102
98
|
|
|
103
|
-
module.exports = ReactNativeComponent;
|
|
99
|
+
module.exports = ReactNativeComponent;
|
package/lib/ReactOwner.js
CHANGED
|
@@ -50,11 +50,8 @@ var ReactOwner = {
|
|
|
50
50
|
* @return {boolean} True if `object` is a valid owner.
|
|
51
51
|
* @final
|
|
52
52
|
*/
|
|
53
|
-
isValidOwner: function(object) {
|
|
54
|
-
return !!(
|
|
55
|
-
(object &&
|
|
56
|
-
typeof object.attachRef === 'function' && typeof object.detachRef === 'function')
|
|
57
|
-
);
|
|
53
|
+
isValidOwner: function (object) {
|
|
54
|
+
return !!(object && typeof object.attachRef === 'function' && typeof object.detachRef === 'function');
|
|
58
55
|
},
|
|
59
56
|
|
|
60
57
|
/**
|
|
@@ -66,15 +63,8 @@ var ReactOwner = {
|
|
|
66
63
|
* @final
|
|
67
64
|
* @internal
|
|
68
65
|
*/
|
|
69
|
-
addComponentAsRefTo: function(component, ref, owner) {
|
|
70
|
-
(
|
|
71
|
-
ReactOwner.isValidOwner(owner),
|
|
72
|
-
'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
|
|
73
|
-
'usually means that you\'re trying to add a ref to a component that ' +
|
|
74
|
-
'doesn\'t have an owner (that is, was not created inside of another ' +
|
|
75
|
-
'component\'s `render` method). Try rendering this component inside of ' +
|
|
76
|
-
'a new top-level component which will hold the ref.'
|
|
77
|
-
) : invariant(ReactOwner.isValidOwner(owner)));
|
|
66
|
+
addComponentAsRefTo: function (component, ref, owner) {
|
|
67
|
+
!ReactOwner.isValidOwner(owner) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to add a ref to a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
|
|
78
68
|
owner.attachRef(ref, component);
|
|
79
69
|
},
|
|
80
70
|
|
|
@@ -87,15 +77,8 @@ var ReactOwner = {
|
|
|
87
77
|
* @final
|
|
88
78
|
* @internal
|
|
89
79
|
*/
|
|
90
|
-
removeComponentAsRefFrom: function(component, ref, owner) {
|
|
91
|
-
(
|
|
92
|
-
ReactOwner.isValidOwner(owner),
|
|
93
|
-
'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
|
|
94
|
-
'usually means that you\'re trying to remove a ref to a component that ' +
|
|
95
|
-
'doesn\'t have an owner (that is, was not created inside of another ' +
|
|
96
|
-
'component\'s `render` method). Try rendering this component inside of ' +
|
|
97
|
-
'a new top-level component which will hold the ref.'
|
|
98
|
-
) : invariant(ReactOwner.isValidOwner(owner)));
|
|
80
|
+
removeComponentAsRefFrom: function (component, ref, owner) {
|
|
81
|
+
!ReactOwner.isValidOwner(owner) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to remove a ref to a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
|
|
99
82
|
// Check that `component` is still the current ref because we do not want to
|
|
100
83
|
// detach the ref if another component stole it.
|
|
101
84
|
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
|
|
@@ -105,4 +88,4 @@ var ReactOwner = {
|
|
|
105
88
|
|
|
106
89
|
};
|
|
107
90
|
|
|
108
|
-
module.exports = ReactOwner;
|
|
91
|
+
module.exports = ReactOwner;
|
package/lib/ReactPerf.js
CHANGED
|
@@ -34,17 +34,13 @@ var ReactPerf = {
|
|
|
34
34
|
* @param {string} objectName
|
|
35
35
|
* @param {object<string>} methodNames
|
|
36
36
|
*/
|
|
37
|
-
measureMethods: function(object, objectName, methodNames) {
|
|
38
|
-
if (
|
|
37
|
+
measureMethods: function (object, objectName, methodNames) {
|
|
38
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
39
39
|
for (var key in methodNames) {
|
|
40
40
|
if (!methodNames.hasOwnProperty(key)) {
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
|
-
object[key] = ReactPerf.measure(
|
|
44
|
-
objectName,
|
|
45
|
-
methodNames[key],
|
|
46
|
-
object[key]
|
|
47
|
-
);
|
|
43
|
+
object[key] = ReactPerf.measure(objectName, methodNames[key], object[key]);
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
},
|
|
@@ -57,10 +53,10 @@ var ReactPerf = {
|
|
|
57
53
|
* @param {function} func
|
|
58
54
|
* @return {function}
|
|
59
55
|
*/
|
|
60
|
-
measure: function(objName, fnName, func) {
|
|
61
|
-
if (
|
|
56
|
+
measure: function (objName, fnName, func) {
|
|
57
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
62
58
|
var measuredFunc = null;
|
|
63
|
-
var wrapper = function() {
|
|
59
|
+
var wrapper = function () {
|
|
64
60
|
if (ReactPerf.enableMeasure) {
|
|
65
61
|
if (!measuredFunc) {
|
|
66
62
|
measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
|
|
@@ -79,7 +75,7 @@ var ReactPerf = {
|
|
|
79
75
|
/**
|
|
80
76
|
* @param {function} measure
|
|
81
77
|
*/
|
|
82
|
-
injectMeasure: function(measure) {
|
|
78
|
+
injectMeasure: function (measure) {
|
|
83
79
|
ReactPerf.storedMeasure = measure;
|
|
84
80
|
}
|
|
85
81
|
}
|
|
@@ -97,4 +93,4 @@ function _noMeasure(objName, fnName, func) {
|
|
|
97
93
|
return func;
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
module.exports = ReactPerf;
|
|
96
|
+
module.exports = ReactPerf;
|
|
@@ -23,7 +23,7 @@ var joinClasses = require("./joinClasses");
|
|
|
23
23
|
* @return {function}
|
|
24
24
|
*/
|
|
25
25
|
function createTransferStrategy(mergeStrategy) {
|
|
26
|
-
return function(props, key, value) {
|
|
26
|
+
return function (props, key, value) {
|
|
27
27
|
if (!props.hasOwnProperty(key)) {
|
|
28
28
|
props[key] = value;
|
|
29
29
|
} else {
|
|
@@ -32,7 +32,7 @@ function createTransferStrategy(mergeStrategy) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
var transferStrategyMerge = createTransferStrategy(function(a, b) {
|
|
35
|
+
var transferStrategyMerge = createTransferStrategy(function (a, b) {
|
|
36
36
|
// `merge` overrides the first object's (`props[key]` above) keys using the
|
|
37
37
|
// second object's (`value`) keys. An object's style's existing `propA` would
|
|
38
38
|
// get overridden. Flip the order here.
|
|
@@ -99,10 +99,10 @@ var ReactPropTransferer = {
|
|
|
99
99
|
* @param {object} newProps new props to merge in
|
|
100
100
|
* @return {object} a new object containing both sets of props merged.
|
|
101
101
|
*/
|
|
102
|
-
mergeProps: function(oldProps, newProps) {
|
|
102
|
+
mergeProps: function (oldProps, newProps) {
|
|
103
103
|
return transferInto(assign({}, oldProps), newProps);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
module.exports = ReactPropTransferer;
|
|
108
|
+
module.exports = ReactPropTransferer;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
var ReactPropTypeLocationNames = {};
|
|
15
15
|
|
|
16
|
-
if (
|
|
16
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
17
17
|
ReactPropTypeLocationNames = {
|
|
18
18
|
prop: 'prop',
|
|
19
19
|
context: 'context',
|
|
@@ -21,4 +21,4 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
module.exports = ReactPropTypeLocationNames;
|
|
24
|
+
module.exports = ReactPropTypeLocationNames;
|
package/lib/ReactPropTypes.js
CHANGED
|
@@ -66,9 +66,6 @@ var emptyFunction = require("./emptyFunction");
|
|
|
66
66
|
|
|
67
67
|
var ANONYMOUS = '<<anonymous>>';
|
|
68
68
|
|
|
69
|
-
var elementTypeChecker = createElementTypeChecker();
|
|
70
|
-
var nodeTypeChecker = createNodeChecker();
|
|
71
|
-
|
|
72
69
|
var ReactPropTypes = {
|
|
73
70
|
array: createPrimitiveTypeChecker('array'),
|
|
74
71
|
bool: createPrimitiveTypeChecker('boolean'),
|
|
@@ -79,9 +76,9 @@ var ReactPropTypes = {
|
|
|
79
76
|
|
|
80
77
|
any: createAnyTypeChecker(),
|
|
81
78
|
arrayOf: createArrayOfTypeChecker,
|
|
82
|
-
element:
|
|
79
|
+
element: createElementTypeChecker(),
|
|
83
80
|
instanceOf: createInstanceTypeChecker,
|
|
84
|
-
node:
|
|
81
|
+
node: createNodeChecker(),
|
|
85
82
|
objectOf: createObjectOfTypeChecker,
|
|
86
83
|
oneOf: createEnumTypeChecker,
|
|
87
84
|
oneOfType: createUnionTypeChecker,
|
|
@@ -89,19 +86,17 @@ var ReactPropTypes = {
|
|
|
89
86
|
};
|
|
90
87
|
|
|
91
88
|
function createChainableTypeChecker(validate) {
|
|
92
|
-
function checkType(isRequired, props, propName, componentName, location) {
|
|
89
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName) {
|
|
93
90
|
componentName = componentName || ANONYMOUS;
|
|
91
|
+
propFullName = propFullName || propName;
|
|
94
92
|
if (props[propName] == null) {
|
|
95
93
|
var locationName = ReactPropTypeLocationNames[location];
|
|
96
94
|
if (isRequired) {
|
|
97
|
-
return new Error(
|
|
98
|
-
("Required " + locationName + " `" + propName + "` was not specified in ") +
|
|
99
|
-
("`" + componentName + "`.")
|
|
100
|
-
);
|
|
95
|
+
return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.'));
|
|
101
96
|
}
|
|
102
97
|
return null;
|
|
103
98
|
} else {
|
|
104
|
-
return validate(props, propName, componentName, location);
|
|
99
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
105
100
|
}
|
|
106
101
|
}
|
|
107
102
|
|
|
@@ -112,7 +107,7 @@ function createChainableTypeChecker(validate) {
|
|
|
112
107
|
}
|
|
113
108
|
|
|
114
109
|
function createPrimitiveTypeChecker(expectedType) {
|
|
115
|
-
function validate(props, propName, componentName, location) {
|
|
110
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
116
111
|
var propValue = props[propName];
|
|
117
112
|
var propType = getPropType(propValue);
|
|
118
113
|
if (propType !== expectedType) {
|
|
@@ -122,10 +117,7 @@ function createPrimitiveTypeChecker(expectedType) {
|
|
|
122
117
|
// 'of type `object`'.
|
|
123
118
|
var preciseType = getPreciseType(propValue);
|
|
124
119
|
|
|
125
|
-
return new Error(
|
|
126
|
-
("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
|
|
127
|
-
("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
|
|
128
|
-
);
|
|
120
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
|
129
121
|
}
|
|
130
122
|
return null;
|
|
131
123
|
}
|
|
@@ -137,18 +129,15 @@ function createAnyTypeChecker() {
|
|
|
137
129
|
}
|
|
138
130
|
|
|
139
131
|
function createArrayOfTypeChecker(typeChecker) {
|
|
140
|
-
function validate(props, propName, componentName, location) {
|
|
132
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
141
133
|
var propValue = props[propName];
|
|
142
134
|
if (!Array.isArray(propValue)) {
|
|
143
135
|
var locationName = ReactPropTypeLocationNames[location];
|
|
144
136
|
var propType = getPropType(propValue);
|
|
145
|
-
return new Error(
|
|
146
|
-
("Invalid " + locationName + " `" + propName + "` of type ") +
|
|
147
|
-
("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
|
|
148
|
-
);
|
|
137
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
149
138
|
}
|
|
150
139
|
for (var i = 0; i < propValue.length; i++) {
|
|
151
|
-
var error = typeChecker(propValue, i, componentName, location);
|
|
140
|
+
var error = typeChecker(propValue, i, componentName, location, '' + propFullName + '[' + i + ']');
|
|
152
141
|
if (error instanceof Error) {
|
|
153
142
|
return error;
|
|
154
143
|
}
|
|
@@ -159,13 +148,10 @@ function createArrayOfTypeChecker(typeChecker) {
|
|
|
159
148
|
}
|
|
160
149
|
|
|
161
150
|
function createElementTypeChecker() {
|
|
162
|
-
function validate(props, propName, componentName, location) {
|
|
151
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
163
152
|
if (!ReactElement.isValidElement(props[propName])) {
|
|
164
153
|
var locationName = ReactPropTypeLocationNames[location];
|
|
165
|
-
return new Error(
|
|
166
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
167
|
-
("`" + componentName + "`, expected a ReactElement.")
|
|
168
|
-
);
|
|
154
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.'));
|
|
169
155
|
}
|
|
170
156
|
return null;
|
|
171
157
|
}
|
|
@@ -173,14 +159,11 @@ function createElementTypeChecker() {
|
|
|
173
159
|
}
|
|
174
160
|
|
|
175
161
|
function createInstanceTypeChecker(expectedClass) {
|
|
176
|
-
function validate(props, propName, componentName, location) {
|
|
162
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
177
163
|
if (!(props[propName] instanceof expectedClass)) {
|
|
178
164
|
var locationName = ReactPropTypeLocationNames[location];
|
|
179
165
|
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
180
|
-
return new Error(
|
|
181
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
182
|
-
("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
|
|
183
|
-
);
|
|
166
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
|
|
184
167
|
}
|
|
185
168
|
return null;
|
|
186
169
|
}
|
|
@@ -188,7 +171,13 @@ function createInstanceTypeChecker(expectedClass) {
|
|
|
188
171
|
}
|
|
189
172
|
|
|
190
173
|
function createEnumTypeChecker(expectedValues) {
|
|
191
|
-
|
|
174
|
+
if (!Array.isArray(expectedValues)) {
|
|
175
|
+
return createChainableTypeChecker(function () {
|
|
176
|
+
return new Error('Invalid argument supplied to oneOf, expected an instance of array.');
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
192
181
|
var propValue = props[propName];
|
|
193
182
|
for (var i = 0; i < expectedValues.length; i++) {
|
|
194
183
|
if (propValue === expectedValues[i]) {
|
|
@@ -198,28 +187,22 @@ function createEnumTypeChecker(expectedValues) {
|
|
|
198
187
|
|
|
199
188
|
var locationName = ReactPropTypeLocationNames[location];
|
|
200
189
|
var valuesString = JSON.stringify(expectedValues);
|
|
201
|
-
return new Error(
|
|
202
|
-
("Invalid " + locationName + " `" + propName + "` of value `" + propValue + "` ") +
|
|
203
|
-
("supplied to `" + componentName + "`, expected one of " + valuesString + ".")
|
|
204
|
-
);
|
|
190
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
205
191
|
}
|
|
206
192
|
return createChainableTypeChecker(validate);
|
|
207
193
|
}
|
|
208
194
|
|
|
209
195
|
function createObjectOfTypeChecker(typeChecker) {
|
|
210
|
-
function validate(props, propName, componentName, location) {
|
|
196
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
211
197
|
var propValue = props[propName];
|
|
212
198
|
var propType = getPropType(propValue);
|
|
213
199
|
if (propType !== 'object') {
|
|
214
200
|
var locationName = ReactPropTypeLocationNames[location];
|
|
215
|
-
return new Error(
|
|
216
|
-
("Invalid " + locationName + " `" + propName + "` of type ") +
|
|
217
|
-
("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
|
|
218
|
-
);
|
|
201
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
219
202
|
}
|
|
220
203
|
for (var key in propValue) {
|
|
221
204
|
if (propValue.hasOwnProperty(key)) {
|
|
222
|
-
var error = typeChecker(propValue, key, componentName, location);
|
|
205
|
+
var error = typeChecker(propValue, key, componentName, location, '' + propFullName + '.' + key);
|
|
223
206
|
if (error instanceof Error) {
|
|
224
207
|
return error;
|
|
225
208
|
}
|
|
@@ -231,31 +214,31 @@ function createObjectOfTypeChecker(typeChecker) {
|
|
|
231
214
|
}
|
|
232
215
|
|
|
233
216
|
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
234
|
-
|
|
217
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
218
|
+
return createChainableTypeChecker(function () {
|
|
219
|
+
return new Error('Invalid argument supplied to oneOfType, expected an instance of array.');
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
235
224
|
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
236
225
|
var checker = arrayOfTypeCheckers[i];
|
|
237
|
-
if (checker(props, propName, componentName, location) == null) {
|
|
226
|
+
if (checker(props, propName, componentName, location, propFullName) == null) {
|
|
238
227
|
return null;
|
|
239
228
|
}
|
|
240
229
|
}
|
|
241
230
|
|
|
242
231
|
var locationName = ReactPropTypeLocationNames[location];
|
|
243
|
-
return new Error(
|
|
244
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
245
|
-
("`" + componentName + "`.")
|
|
246
|
-
);
|
|
232
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
|
247
233
|
}
|
|
248
234
|
return createChainableTypeChecker(validate);
|
|
249
235
|
}
|
|
250
236
|
|
|
251
237
|
function createNodeChecker() {
|
|
252
|
-
function validate(props, propName, componentName, location) {
|
|
238
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
253
239
|
if (!isNode(props[propName])) {
|
|
254
240
|
var locationName = ReactPropTypeLocationNames[location];
|
|
255
|
-
return new Error(
|
|
256
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
257
|
-
("`" + componentName + "`, expected a ReactNode.")
|
|
258
|
-
);
|
|
241
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
259
242
|
}
|
|
260
243
|
return null;
|
|
261
244
|
}
|
|
@@ -263,22 +246,19 @@ function createNodeChecker() {
|
|
|
263
246
|
}
|
|
264
247
|
|
|
265
248
|
function createShapeTypeChecker(shapeTypes) {
|
|
266
|
-
function validate(props, propName, componentName, location) {
|
|
249
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
267
250
|
var propValue = props[propName];
|
|
268
251
|
var propType = getPropType(propValue);
|
|
269
252
|
if (propType !== 'object') {
|
|
270
253
|
var locationName = ReactPropTypeLocationNames[location];
|
|
271
|
-
return new Error(
|
|
272
|
-
("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
|
|
273
|
-
("supplied to `" + componentName + "`, expected `object`.")
|
|
274
|
-
);
|
|
254
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
275
255
|
}
|
|
276
256
|
for (var key in shapeTypes) {
|
|
277
257
|
var checker = shapeTypes[key];
|
|
278
258
|
if (!checker) {
|
|
279
259
|
continue;
|
|
280
260
|
}
|
|
281
|
-
var error = checker(propValue, key, componentName, location);
|
|
261
|
+
var error = checker(propValue, key, componentName, location, '' + propFullName + '.' + key);
|
|
282
262
|
if (error) {
|
|
283
263
|
return error;
|
|
284
264
|
}
|
|
@@ -344,4 +324,4 @@ function getPreciseType(propValue) {
|
|
|
344
324
|
return propType;
|
|
345
325
|
}
|
|
346
326
|
|
|
347
|
-
module.exports = ReactPropTypes;
|
|
327
|
+
module.exports = ReactPropTypes;
|