react 0.13.3 → 0.14.0-alpha1
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/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 +3092 -5145
- package/dist/react-with-addons.min.js +6 -8
- package/dist/react.js +2772 -4594
- package/dist/react.min.js +5 -6
- 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 -65
- package/lib/DOMPropertyOperations.js +30 -51
- package/lib/Danger.js +19 -60
- 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 +5 -17
- 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 +20 -38
- 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 +7 -16
- package/lib/ReactClass.js +78 -231
- package/lib/ReactComponent.js +17 -51
- package/lib/ReactComponentBrowserEnvironment.js +4 -6
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +4 -5
- package/lib/ReactCompositeComponent.js +83 -318
- package/lib/ReactContext.js +2 -44
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +3 -2
- package/lib/ReactDOMButton.js +3 -4
- package/lib/ReactDOMComponent.js +182 -148
- package/lib/ReactDOMForm.js +3 -3
- package/lib/ReactDOMIDOperations.js +11 -20
- package/lib/ReactDOMIframe.js +3 -3
- package/lib/ReactDOMImg.js +3 -3
- package/lib/ReactDOMInput.js +22 -35
- package/lib/ReactDOMOption.js +52 -10
- package/lib/ReactDOMSelect.js +50 -28
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +15 -27
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +21 -40
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +35 -72
- package/lib/ReactElementValidator.js +51 -110
- 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/ReactLifeCycle.js +1 -1
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +136 -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 +13 -46
- 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 +89 -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 +39 -2
- 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 -2
- 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 +5 -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 +19 -82
- package/lib/update.js +25 -85
- package/lib/validateDOMNesting.js +264 -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
|
+
'production' !== process.env.NODE_ENV ? invariant(genericComponentClass, 'There is no registered component for the tag %s', element.type) : invariant(genericComponentClass);
|
|
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
|
+
'production' !== process.env.NODE_ENV ? invariant(ReactOwner.isValidOwner(owner), '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(ReactOwner.isValidOwner(owner));
|
|
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
|
+
'production' !== process.env.NODE_ENV ? invariant(ReactOwner.isValidOwner(owner), '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(ReactOwner.isValidOwner(owner));
|
|
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,
|
|
@@ -94,10 +91,7 @@ function createChainableTypeChecker(validate) {
|
|
|
94
91
|
if (props[propName] == null) {
|
|
95
92
|
var locationName = ReactPropTypeLocationNames[location];
|
|
96
93
|
if (isRequired) {
|
|
97
|
-
return new Error(
|
|
98
|
-
("Required " + locationName + " `" + propName + "` was not specified in ") +
|
|
99
|
-
("`" + componentName + "`.")
|
|
100
|
-
);
|
|
94
|
+
return new Error('Required ' + locationName + ' `' + propName + '` was not specified in ' + ('`' + componentName + '`.'));
|
|
101
95
|
}
|
|
102
96
|
return null;
|
|
103
97
|
} else {
|
|
@@ -122,10 +116,7 @@ function createPrimitiveTypeChecker(expectedType) {
|
|
|
122
116
|
// 'of type `object`'.
|
|
123
117
|
var preciseType = getPreciseType(propValue);
|
|
124
118
|
|
|
125
|
-
return new Error(
|
|
126
|
-
("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
|
|
127
|
-
("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
|
|
128
|
-
);
|
|
119
|
+
return new Error('Invalid ' + locationName + ' `' + propName + '` of type `' + preciseType + '` ' + ('supplied to `' + componentName + '`, expected `' + expectedType + '`.'));
|
|
129
120
|
}
|
|
130
121
|
return null;
|
|
131
122
|
}
|
|
@@ -142,10 +133,7 @@ function createArrayOfTypeChecker(typeChecker) {
|
|
|
142
133
|
if (!Array.isArray(propValue)) {
|
|
143
134
|
var locationName = ReactPropTypeLocationNames[location];
|
|
144
135
|
var propType = getPropType(propValue);
|
|
145
|
-
return new Error(
|
|
146
|
-
("Invalid " + locationName + " `" + propName + "` of type ") +
|
|
147
|
-
("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
|
|
148
|
-
);
|
|
136
|
+
return new Error('Invalid ' + locationName + ' `' + propName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
149
137
|
}
|
|
150
138
|
for (var i = 0; i < propValue.length; i++) {
|
|
151
139
|
var error = typeChecker(propValue, i, componentName, location);
|
|
@@ -162,10 +150,7 @@ function createElementTypeChecker() {
|
|
|
162
150
|
function validate(props, propName, componentName, location) {
|
|
163
151
|
if (!ReactElement.isValidElement(props[propName])) {
|
|
164
152
|
var locationName = ReactPropTypeLocationNames[location];
|
|
165
|
-
return new Error(
|
|
166
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
167
|
-
("`" + componentName + "`, expected a ReactElement.")
|
|
168
|
-
);
|
|
153
|
+
return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`, expected a ReactElement.'));
|
|
169
154
|
}
|
|
170
155
|
return null;
|
|
171
156
|
}
|
|
@@ -177,10 +162,7 @@ function createInstanceTypeChecker(expectedClass) {
|
|
|
177
162
|
if (!(props[propName] instanceof expectedClass)) {
|
|
178
163
|
var locationName = ReactPropTypeLocationNames[location];
|
|
179
164
|
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
180
|
-
return new Error(
|
|
181
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
182
|
-
("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
|
|
183
|
-
);
|
|
165
|
+
return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
|
|
184
166
|
}
|
|
185
167
|
return null;
|
|
186
168
|
}
|
|
@@ -198,10 +180,7 @@ function createEnumTypeChecker(expectedValues) {
|
|
|
198
180
|
|
|
199
181
|
var locationName = ReactPropTypeLocationNames[location];
|
|
200
182
|
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
|
-
);
|
|
183
|
+
return new Error('Invalid ' + locationName + ' `' + propName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
205
184
|
}
|
|
206
185
|
return createChainableTypeChecker(validate);
|
|
207
186
|
}
|
|
@@ -212,10 +191,7 @@ function createObjectOfTypeChecker(typeChecker) {
|
|
|
212
191
|
var propType = getPropType(propValue);
|
|
213
192
|
if (propType !== 'object') {
|
|
214
193
|
var locationName = ReactPropTypeLocationNames[location];
|
|
215
|
-
return new Error(
|
|
216
|
-
("Invalid " + locationName + " `" + propName + "` of type ") +
|
|
217
|
-
("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
|
|
218
|
-
);
|
|
194
|
+
return new Error('Invalid ' + locationName + ' `' + propName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
219
195
|
}
|
|
220
196
|
for (var key in propValue) {
|
|
221
197
|
if (propValue.hasOwnProperty(key)) {
|
|
@@ -240,10 +216,7 @@ function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
|
240
216
|
}
|
|
241
217
|
|
|
242
218
|
var locationName = ReactPropTypeLocationNames[location];
|
|
243
|
-
return new Error(
|
|
244
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
245
|
-
("`" + componentName + "`.")
|
|
246
|
-
);
|
|
219
|
+
return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`.'));
|
|
247
220
|
}
|
|
248
221
|
return createChainableTypeChecker(validate);
|
|
249
222
|
}
|
|
@@ -252,10 +225,7 @@ function createNodeChecker() {
|
|
|
252
225
|
function validate(props, propName, componentName, location) {
|
|
253
226
|
if (!isNode(props[propName])) {
|
|
254
227
|
var locationName = ReactPropTypeLocationNames[location];
|
|
255
|
-
return new Error(
|
|
256
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
257
|
-
("`" + componentName + "`, expected a ReactNode.")
|
|
258
|
-
);
|
|
228
|
+
return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
259
229
|
}
|
|
260
230
|
return null;
|
|
261
231
|
}
|
|
@@ -268,10 +238,7 @@ function createShapeTypeChecker(shapeTypes) {
|
|
|
268
238
|
var propType = getPropType(propValue);
|
|
269
239
|
if (propType !== 'object') {
|
|
270
240
|
var locationName = ReactPropTypeLocationNames[location];
|
|
271
|
-
return new Error(
|
|
272
|
-
("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
|
|
273
|
-
("supplied to `" + componentName + "`, expected `object`.")
|
|
274
|
-
);
|
|
241
|
+
return new Error('Invalid ' + locationName + ' `' + propName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
275
242
|
}
|
|
276
243
|
for (var key in shapeTypes) {
|
|
277
244
|
var checker = shapeTypes[key];
|
|
@@ -344,4 +311,4 @@ function getPreciseType(propValue) {
|
|
|
344
311
|
return propType;
|
|
345
312
|
}
|
|
346
313
|
|
|
347
|
-
module.exports = ReactPropTypes;
|
|
314
|
+
module.exports = ReactPropTypes;
|