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
|
@@ -33,7 +33,7 @@ var ReactChildReconciler = {
|
|
|
33
33
|
* @return {?object} A set of child instances.
|
|
34
34
|
* @internal
|
|
35
35
|
*/
|
|
36
|
-
instantiateChildren: function(nestedChildNodes, transaction, context) {
|
|
36
|
+
instantiateChildren: function (nestedChildNodes, transaction, context) {
|
|
37
37
|
var children = flattenChildren(nestedChildNodes);
|
|
38
38
|
for (var name in children) {
|
|
39
39
|
if (children.hasOwnProperty(name)) {
|
|
@@ -57,11 +57,7 @@ var ReactChildReconciler = {
|
|
|
57
57
|
* @return {?object} A new set of child instances.
|
|
58
58
|
* @internal
|
|
59
59
|
*/
|
|
60
|
-
updateChildren: function(
|
|
61
|
-
prevChildren,
|
|
62
|
-
nextNestedChildNodes,
|
|
63
|
-
transaction,
|
|
64
|
-
context) {
|
|
60
|
+
updateChildren: function (prevChildren, nextNestedChildNodes, transaction, context) {
|
|
65
61
|
// We currently don't have a way to track moves here but if we use iterators
|
|
66
62
|
// instead of for..in we can zip the iterators and check if an item has
|
|
67
63
|
// moved.
|
|
@@ -80,26 +76,20 @@ var ReactChildReconciler = {
|
|
|
80
76
|
var prevElement = prevChild && prevChild._currentElement;
|
|
81
77
|
var nextElement = nextChildren[name];
|
|
82
78
|
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
83
|
-
ReactReconciler.receiveComponent(
|
|
84
|
-
prevChild, nextElement, transaction, context
|
|
85
|
-
);
|
|
79
|
+
ReactReconciler.receiveComponent(prevChild, nextElement, transaction, context);
|
|
86
80
|
nextChildren[name] = prevChild;
|
|
87
81
|
} else {
|
|
88
82
|
if (prevChild) {
|
|
89
83
|
ReactReconciler.unmountComponent(prevChild, name);
|
|
90
84
|
}
|
|
91
85
|
// The child must be instantiated before it's mounted.
|
|
92
|
-
var nextChildInstance = instantiateReactComponent(
|
|
93
|
-
nextElement,
|
|
94
|
-
null
|
|
95
|
-
);
|
|
86
|
+
var nextChildInstance = instantiateReactComponent(nextElement, null);
|
|
96
87
|
nextChildren[name] = nextChildInstance;
|
|
97
88
|
}
|
|
98
89
|
}
|
|
99
90
|
// Unmount children that are no longer present.
|
|
100
91
|
for (name in prevChildren) {
|
|
101
|
-
if (prevChildren.hasOwnProperty(name) &&
|
|
102
|
-
!(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
92
|
+
if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
103
93
|
ReactReconciler.unmountComponent(prevChildren[name]);
|
|
104
94
|
}
|
|
105
95
|
}
|
|
@@ -113,13 +103,15 @@ var ReactChildReconciler = {
|
|
|
113
103
|
* @param {?object} renderedChildren Previously initialized set of children.
|
|
114
104
|
* @internal
|
|
115
105
|
*/
|
|
116
|
-
unmountChildren: function(renderedChildren) {
|
|
106
|
+
unmountChildren: function (renderedChildren) {
|
|
117
107
|
for (var name in renderedChildren) {
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
if (renderedChildren.hasOwnProperty(name)) {
|
|
109
|
+
var renderedChild = renderedChildren[name];
|
|
110
|
+
ReactReconciler.unmountComponent(renderedChild);
|
|
111
|
+
}
|
|
120
112
|
}
|
|
121
113
|
}
|
|
122
114
|
|
|
123
115
|
};
|
|
124
116
|
|
|
125
|
-
module.exports = ReactChildReconciler;
|
|
117
|
+
module.exports = ReactChildReconciler;
|
package/lib/ReactChildren.js
CHANGED
|
@@ -29,15 +29,15 @@ var threeArgumentPooler = PooledClass.threeArgumentPooler;
|
|
|
29
29
|
* @param {?*} forEachContext Context to perform context with.
|
|
30
30
|
*/
|
|
31
31
|
function ForEachBookKeeping(forEachFunction, forEachContext) {
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
32
|
+
this.func = forEachFunction;
|
|
33
|
+
this.context = forEachContext;
|
|
34
|
+
this.count = 0;
|
|
34
35
|
}
|
|
35
36
|
PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
|
|
36
37
|
|
|
37
|
-
function forEachSingleChild(traverseContext, child, name
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
forEachBookKeeping.forEachContext, child, i);
|
|
38
|
+
function forEachSingleChild(traverseContext, child, name) {
|
|
39
|
+
var bookKeeping = traverseContext;
|
|
40
|
+
bookKeeping.func.call(bookKeeping.context, child, bookKeeping.count++);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -55,8 +55,7 @@ function forEachChildren(children, forEachFunc, forEachContext) {
|
|
|
55
55
|
return children;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
var traverseContext =
|
|
59
|
-
ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
|
|
58
|
+
var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
|
|
60
59
|
traverseAllChildren(children, forEachSingleChild, traverseContext);
|
|
61
60
|
ForEachBookKeeping.release(traverseContext);
|
|
62
61
|
}
|
|
@@ -71,30 +70,24 @@ function forEachChildren(children, forEachFunc, forEachContext) {
|
|
|
71
70
|
* @param {?*} mapContext Context to perform mapping with.
|
|
72
71
|
*/
|
|
73
72
|
function MapBookKeeping(mapResult, mapFunction, mapContext) {
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
73
|
+
this.result = mapResult;
|
|
74
|
+
this.func = mapFunction;
|
|
75
|
+
this.context = mapContext;
|
|
76
|
+
this.count = 0;
|
|
77
77
|
}
|
|
78
78
|
PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
|
|
79
79
|
|
|
80
|
-
function mapSingleChildIntoContext(traverseContext, child, name
|
|
81
|
-
var
|
|
82
|
-
var mapResult =
|
|
83
|
-
|
|
84
|
-
var keyUnique =
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
keyUnique,
|
|
88
|
-
'ReactChildren.map(...): Encountered two children with the same key, ' +
|
|
89
|
-
'`%s`. Child keys must be unique; when two children share a key, only ' +
|
|
90
|
-
'the first child will be used.',
|
|
91
|
-
name
|
|
92
|
-
) : null);
|
|
80
|
+
function mapSingleChildIntoContext(traverseContext, child, name) {
|
|
81
|
+
var bookKeeping = traverseContext;
|
|
82
|
+
var mapResult = bookKeeping.result;
|
|
83
|
+
|
|
84
|
+
var keyUnique = mapResult[name] === undefined;
|
|
85
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
86
|
+
'production' !== process.env.NODE_ENV ? warning(keyUnique, 'ReactChildren.map(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : undefined;
|
|
93
87
|
}
|
|
94
88
|
|
|
95
89
|
if (keyUnique) {
|
|
96
|
-
var mappedChild =
|
|
97
|
-
mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
|
|
90
|
+
var mappedChild = bookKeeping.func.call(bookKeeping.context, child, bookKeeping.count++);
|
|
98
91
|
mapResult[name] = mappedChild;
|
|
99
92
|
}
|
|
100
93
|
}
|
|
@@ -125,7 +118,7 @@ function mapChildren(children, func, context) {
|
|
|
125
118
|
return ReactFragment.create(mapResult);
|
|
126
119
|
}
|
|
127
120
|
|
|
128
|
-
function forEachSingleChildDummy(traverseContext, child, name
|
|
121
|
+
function forEachSingleChildDummy(traverseContext, child, name) {
|
|
129
122
|
return null;
|
|
130
123
|
}
|
|
131
124
|
|
|
@@ -146,4 +139,4 @@ var ReactChildren = {
|
|
|
146
139
|
count: countChildren
|
|
147
140
|
};
|
|
148
141
|
|
|
149
|
-
module.exports = ReactChildren;
|
|
142
|
+
module.exports = ReactChildren;
|
package/lib/ReactClass.js
CHANGED
|
@@ -27,7 +27,7 @@ var keyMirror = require("./keyMirror");
|
|
|
27
27
|
var keyOf = require("./keyOf");
|
|
28
28
|
var warning = require("./warning");
|
|
29
29
|
|
|
30
|
-
var MIXINS_KEY = keyOf({mixins: null});
|
|
30
|
+
var MIXINS_KEY = keyOf({ mixins: null });
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Policies that describe methods in `ReactClassInterface`.
|
|
@@ -54,7 +54,6 @@ var SpecPolicy = keyMirror({
|
|
|
54
54
|
DEFINE_MANY_MERGED: null
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
|
|
58
57
|
var injectedMixins = [];
|
|
59
58
|
|
|
60
59
|
/**
|
|
@@ -74,7 +73,7 @@ var injectedMixins = [];
|
|
|
74
73
|
* The class specification supports a specific protocol of methods that have
|
|
75
74
|
* special meaning (e.g. `render`). See `ReactClassInterface` for
|
|
76
75
|
* more the comprehensive protocol. Any other properties and methods in the
|
|
77
|
-
* class specification will available on the prototype.
|
|
76
|
+
* class specification will be available on the prototype.
|
|
78
77
|
*
|
|
79
78
|
* @interface ReactClassInterface
|
|
80
79
|
* @internal
|
|
@@ -176,8 +175,6 @@ var ReactClassInterface = {
|
|
|
176
175
|
*/
|
|
177
176
|
render: SpecPolicy.DEFINE_ONCE,
|
|
178
177
|
|
|
179
|
-
|
|
180
|
-
|
|
181
178
|
// ==== Delegate methods ====
|
|
182
179
|
|
|
183
180
|
/**
|
|
@@ -288,8 +285,6 @@ var ReactClassInterface = {
|
|
|
288
285
|
*/
|
|
289
286
|
componentWillUnmount: SpecPolicy.DEFINE_MANY,
|
|
290
287
|
|
|
291
|
-
|
|
292
|
-
|
|
293
288
|
// ==== Advanced methods ====
|
|
294
289
|
|
|
295
290
|
/**
|
|
@@ -316,73 +311,46 @@ var ReactClassInterface = {
|
|
|
316
311
|
* which all other static methods are defined.
|
|
317
312
|
*/
|
|
318
313
|
var RESERVED_SPEC_KEYS = {
|
|
319
|
-
displayName: function(Constructor, displayName) {
|
|
314
|
+
displayName: function (Constructor, displayName) {
|
|
320
315
|
Constructor.displayName = displayName;
|
|
321
316
|
},
|
|
322
|
-
mixins: function(Constructor, mixins) {
|
|
317
|
+
mixins: function (Constructor, mixins) {
|
|
323
318
|
if (mixins) {
|
|
324
319
|
for (var i = 0; i < mixins.length; i++) {
|
|
325
320
|
mixSpecIntoComponent(Constructor, mixins[i]);
|
|
326
321
|
}
|
|
327
322
|
}
|
|
328
323
|
},
|
|
329
|
-
childContextTypes: function(Constructor, childContextTypes) {
|
|
330
|
-
if (
|
|
331
|
-
validateTypeDef(
|
|
332
|
-
Constructor,
|
|
333
|
-
childContextTypes,
|
|
334
|
-
ReactPropTypeLocations.childContext
|
|
335
|
-
);
|
|
324
|
+
childContextTypes: function (Constructor, childContextTypes) {
|
|
325
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
326
|
+
validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
|
|
336
327
|
}
|
|
337
|
-
Constructor.childContextTypes = assign(
|
|
338
|
-
{},
|
|
339
|
-
Constructor.childContextTypes,
|
|
340
|
-
childContextTypes
|
|
341
|
-
);
|
|
328
|
+
Constructor.childContextTypes = assign({}, Constructor.childContextTypes, childContextTypes);
|
|
342
329
|
},
|
|
343
|
-
contextTypes: function(Constructor, contextTypes) {
|
|
344
|
-
if (
|
|
345
|
-
validateTypeDef(
|
|
346
|
-
Constructor,
|
|
347
|
-
contextTypes,
|
|
348
|
-
ReactPropTypeLocations.context
|
|
349
|
-
);
|
|
330
|
+
contextTypes: function (Constructor, contextTypes) {
|
|
331
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
332
|
+
validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
|
|
350
333
|
}
|
|
351
|
-
Constructor.contextTypes = assign(
|
|
352
|
-
{},
|
|
353
|
-
Constructor.contextTypes,
|
|
354
|
-
contextTypes
|
|
355
|
-
);
|
|
334
|
+
Constructor.contextTypes = assign({}, Constructor.contextTypes, contextTypes);
|
|
356
335
|
},
|
|
357
336
|
/**
|
|
358
337
|
* Special case getDefaultProps which should move into statics but requires
|
|
359
338
|
* automatic merging.
|
|
360
339
|
*/
|
|
361
|
-
getDefaultProps: function(Constructor, getDefaultProps) {
|
|
340
|
+
getDefaultProps: function (Constructor, getDefaultProps) {
|
|
362
341
|
if (Constructor.getDefaultProps) {
|
|
363
|
-
Constructor.getDefaultProps = createMergedResultFunction(
|
|
364
|
-
Constructor.getDefaultProps,
|
|
365
|
-
getDefaultProps
|
|
366
|
-
);
|
|
342
|
+
Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
|
|
367
343
|
} else {
|
|
368
344
|
Constructor.getDefaultProps = getDefaultProps;
|
|
369
345
|
}
|
|
370
346
|
},
|
|
371
|
-
propTypes: function(Constructor, propTypes) {
|
|
372
|
-
if (
|
|
373
|
-
validateTypeDef(
|
|
374
|
-
Constructor,
|
|
375
|
-
propTypes,
|
|
376
|
-
ReactPropTypeLocations.prop
|
|
377
|
-
);
|
|
347
|
+
propTypes: function (Constructor, propTypes) {
|
|
348
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
349
|
+
validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
|
|
378
350
|
}
|
|
379
|
-
Constructor.propTypes = assign(
|
|
380
|
-
{},
|
|
381
|
-
Constructor.propTypes,
|
|
382
|
-
propTypes
|
|
383
|
-
);
|
|
351
|
+
Constructor.propTypes = assign({}, Constructor.propTypes, propTypes);
|
|
384
352
|
},
|
|
385
|
-
statics: function(Constructor, statics) {
|
|
353
|
+
statics: function (Constructor, statics) {
|
|
386
354
|
mixStaticSpecIntoComponent(Constructor, statics);
|
|
387
355
|
}
|
|
388
356
|
};
|
|
@@ -392,45 +360,22 @@ function validateTypeDef(Constructor, typeDef, location) {
|
|
|
392
360
|
if (typeDef.hasOwnProperty(propName)) {
|
|
393
361
|
// use a warning instead of an invariant so components
|
|
394
362
|
// don't show up in prod but not in __DEV__
|
|
395
|
-
|
|
396
|
-
typeof typeDef[propName] === 'function',
|
|
397
|
-
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
|
|
398
|
-
'React.PropTypes.',
|
|
399
|
-
Constructor.displayName || 'ReactClass',
|
|
400
|
-
ReactPropTypeLocationNames[location],
|
|
401
|
-
propName
|
|
402
|
-
) : null);
|
|
363
|
+
'production' !== process.env.NODE_ENV ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : undefined;
|
|
403
364
|
}
|
|
404
365
|
}
|
|
405
366
|
}
|
|
406
367
|
|
|
407
368
|
function validateMethodOverride(proto, name) {
|
|
408
|
-
var specPolicy = ReactClassInterface.hasOwnProperty(name) ?
|
|
409
|
-
ReactClassInterface[name] :
|
|
410
|
-
null;
|
|
369
|
+
var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
|
|
411
370
|
|
|
412
371
|
// Disallow overriding of base class methods unless explicitly allowed.
|
|
413
372
|
if (ReactClassMixin.hasOwnProperty(name)) {
|
|
414
|
-
(
|
|
415
|
-
specPolicy === SpecPolicy.OVERRIDE_BASE,
|
|
416
|
-
'ReactClassInterface: You are attempting to override ' +
|
|
417
|
-
'`%s` from your class specification. Ensure that your method names ' +
|
|
418
|
-
'do not overlap with React methods.',
|
|
419
|
-
name
|
|
420
|
-
) : invariant(specPolicy === SpecPolicy.OVERRIDE_BASE));
|
|
373
|
+
!(specPolicy === SpecPolicy.OVERRIDE_BASE) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name) : invariant(false) : undefined;
|
|
421
374
|
}
|
|
422
375
|
|
|
423
376
|
// Disallow defining methods more than once unless explicitly allowed.
|
|
424
377
|
if (proto.hasOwnProperty(name)) {
|
|
425
|
-
(
|
|
426
|
-
specPolicy === SpecPolicy.DEFINE_MANY ||
|
|
427
|
-
specPolicy === SpecPolicy.DEFINE_MANY_MERGED,
|
|
428
|
-
'ReactClassInterface: You are attempting to define ' +
|
|
429
|
-
'`%s` on your component more than once. This conflict may be due ' +
|
|
430
|
-
'to a mixin.',
|
|
431
|
-
name
|
|
432
|
-
) : invariant(specPolicy === SpecPolicy.DEFINE_MANY ||
|
|
433
|
-
specPolicy === SpecPolicy.DEFINE_MANY_MERGED));
|
|
378
|
+
!(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name) : invariant(false) : undefined;
|
|
434
379
|
}
|
|
435
380
|
}
|
|
436
381
|
|
|
@@ -443,16 +388,8 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
443
388
|
return;
|
|
444
389
|
}
|
|
445
390
|
|
|
446
|
-
(
|
|
447
|
-
|
|
448
|
-
'ReactClass: You\'re attempting to ' +
|
|
449
|
-
'use a component class as a mixin. Instead, just use a regular object.'
|
|
450
|
-
) : invariant(typeof spec !== 'function'));
|
|
451
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
452
|
-
!ReactElement.isValidElement(spec),
|
|
453
|
-
'ReactClass: You\'re attempting to ' +
|
|
454
|
-
'use a component as a mixin. Instead, just use a regular object.'
|
|
455
|
-
) : invariant(!ReactElement.isValidElement(spec)));
|
|
391
|
+
!(typeof spec !== 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
|
|
392
|
+
!!ReactElement.isValidElement(spec) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
|
|
456
393
|
|
|
457
394
|
var proto = Constructor.prototype;
|
|
458
395
|
|
|
@@ -469,7 +406,7 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
469
406
|
}
|
|
470
407
|
|
|
471
408
|
if (name === MIXINS_KEY) {
|
|
472
|
-
// We have already handled mixins in a special case above
|
|
409
|
+
// We have already handled mixins in a special case above.
|
|
473
410
|
continue;
|
|
474
411
|
}
|
|
475
412
|
|
|
@@ -483,16 +420,10 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
483
420
|
// The following member methods should not be automatically bound:
|
|
484
421
|
// 1. Expected ReactClass methods (in the "interface").
|
|
485
422
|
// 2. Overridden methods (that were mixed in).
|
|
486
|
-
var isReactClassMethod =
|
|
487
|
-
ReactClassInterface.hasOwnProperty(name);
|
|
423
|
+
var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
|
|
488
424
|
var isAlreadyDefined = proto.hasOwnProperty(name);
|
|
489
|
-
var markedDontBind = property && property.__reactDontBind;
|
|
490
425
|
var isFunction = typeof property === 'function';
|
|
491
|
-
var shouldAutoBind =
|
|
492
|
-
isFunction &&
|
|
493
|
-
!isReactClassMethod &&
|
|
494
|
-
!isAlreadyDefined &&
|
|
495
|
-
!markedDontBind;
|
|
426
|
+
var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined;
|
|
496
427
|
|
|
497
428
|
if (shouldAutoBind) {
|
|
498
429
|
if (!proto.__reactAutoBindMap) {
|
|
@@ -504,18 +435,8 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
504
435
|
if (isAlreadyDefined) {
|
|
505
436
|
var specPolicy = ReactClassInterface[name];
|
|
506
437
|
|
|
507
|
-
// These cases should already be caught by validateMethodOverride
|
|
508
|
-
(
|
|
509
|
-
isReactClassMethod && (
|
|
510
|
-
(specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
|
|
511
|
-
),
|
|
512
|
-
'ReactClass: Unexpected spec policy %s for key %s ' +
|
|
513
|
-
'when mixing in component specs.',
|
|
514
|
-
specPolicy,
|
|
515
|
-
name
|
|
516
|
-
) : invariant(isReactClassMethod && (
|
|
517
|
-
(specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
|
|
518
|
-
)));
|
|
438
|
+
// These cases should already be caught by validateMethodOverride.
|
|
439
|
+
!(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(false) : undefined;
|
|
519
440
|
|
|
520
441
|
// For methods which are defined more than once, call the existing
|
|
521
442
|
// methods before calling the new property, merging if appropriate.
|
|
@@ -526,7 +447,7 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
526
447
|
}
|
|
527
448
|
} else {
|
|
528
449
|
proto[name] = property;
|
|
529
|
-
if (
|
|
450
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
530
451
|
// Add verbose displayName to the function, which helps when looking
|
|
531
452
|
// at profiling tools.
|
|
532
453
|
if (typeof property === 'function' && spec.displayName) {
|
|
@@ -549,24 +470,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
549
470
|
continue;
|
|
550
471
|
}
|
|
551
472
|
|
|
552
|
-
var isReserved = name in RESERVED_SPEC_KEYS;
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
'as an instance property instead; it will still be accessible on the ' +
|
|
558
|
-
'constructor.',
|
|
559
|
-
name
|
|
560
|
-
) : invariant(!isReserved));
|
|
561
|
-
|
|
562
|
-
var isInherited = name in Constructor;
|
|
563
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
564
|
-
!isInherited,
|
|
565
|
-
'ReactClass: You are attempting to define ' +
|
|
566
|
-
'`%s` on your component more than once. This conflict may be ' +
|
|
567
|
-
'due to a mixin.',
|
|
568
|
-
name
|
|
569
|
-
) : invariant(!isInherited));
|
|
473
|
+
var isReserved = (name in RESERVED_SPEC_KEYS);
|
|
474
|
+
!!isReserved ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClass: You are attempting to define a reserved ' + 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + 'as an instance property instead; it will still be accessible on the ' + 'constructor.', name) : invariant(false) : undefined;
|
|
475
|
+
|
|
476
|
+
var isInherited = (name in Constructor);
|
|
477
|
+
!!isInherited ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name) : invariant(false) : undefined;
|
|
570
478
|
Constructor[name] = property;
|
|
571
479
|
}
|
|
572
480
|
}
|
|
@@ -579,22 +487,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
579
487
|
* @return {object} one after it has been mutated to contain everything in two.
|
|
580
488
|
*/
|
|
581
489
|
function mergeIntoWithNoDuplicateKeys(one, two) {
|
|
582
|
-
(
|
|
583
|
-
one && two && typeof one === 'object' && typeof two === 'object',
|
|
584
|
-
'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'
|
|
585
|
-
) : invariant(one && two && typeof one === 'object' && typeof two === 'object'));
|
|
490
|
+
!(one && two && typeof one === 'object' && typeof two === 'object') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : undefined;
|
|
586
491
|
|
|
587
492
|
for (var key in two) {
|
|
588
493
|
if (two.hasOwnProperty(key)) {
|
|
589
|
-
(
|
|
590
|
-
one[key] === undefined,
|
|
591
|
-
'mergeIntoWithNoDuplicateKeys(): ' +
|
|
592
|
-
'Tried to merge two objects with the same key: `%s`. This conflict ' +
|
|
593
|
-
'may be due to a mixin; in particular, this may be caused by two ' +
|
|
594
|
-
'getInitialState() or getDefaultProps() methods returning objects ' +
|
|
595
|
-
'with clashing keys.',
|
|
596
|
-
key
|
|
597
|
-
) : invariant(one[key] === undefined));
|
|
494
|
+
!(one[key] === undefined) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key) : invariant(false) : undefined;
|
|
598
495
|
one[key] = two[key];
|
|
599
496
|
}
|
|
600
497
|
}
|
|
@@ -649,32 +546,25 @@ function createChainedFunction(one, two) {
|
|
|
649
546
|
*/
|
|
650
547
|
function bindAutoBindMethod(component, method) {
|
|
651
548
|
var boundMethod = method.bind(component);
|
|
652
|
-
if (
|
|
549
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
653
550
|
boundMethod.__reactBoundContext = component;
|
|
654
551
|
boundMethod.__reactBoundMethod = method;
|
|
655
552
|
boundMethod.__reactBoundArguments = null;
|
|
656
553
|
var componentName = component.constructor.displayName;
|
|
657
554
|
var _bind = boundMethod.bind;
|
|
658
555
|
/* eslint-disable block-scoped-var, no-undef */
|
|
659
|
-
boundMethod.bind = function(newThis
|
|
556
|
+
boundMethod.bind = function (newThis) {
|
|
557
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
558
|
+
args[_key - 1] = arguments[_key];
|
|
559
|
+
}
|
|
560
|
+
|
|
660
561
|
// User is trying to bind() an autobound method; we effectively will
|
|
661
562
|
// ignore the value of "this" that the user is trying to use, so
|
|
662
563
|
// let's warn.
|
|
663
564
|
if (newThis !== component && newThis !== null) {
|
|
664
|
-
|
|
665
|
-
false,
|
|
666
|
-
'bind(): React component methods may only be bound to the ' +
|
|
667
|
-
'component instance. See %s',
|
|
668
|
-
componentName
|
|
669
|
-
) : null);
|
|
565
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : undefined;
|
|
670
566
|
} else if (!args.length) {
|
|
671
|
-
|
|
672
|
-
false,
|
|
673
|
-
'bind(): You are binding a component method to the component. ' +
|
|
674
|
-
'React does this for you automatically in a high-performance ' +
|
|
675
|
-
'way, so you can safely remove this call. See %s',
|
|
676
|
-
componentName
|
|
677
|
-
) : null);
|
|
567
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : undefined;
|
|
678
568
|
return boundMethod;
|
|
679
569
|
}
|
|
680
570
|
var reboundMethod = _bind.apply(boundMethod, arguments);
|
|
@@ -697,27 +587,16 @@ function bindAutoBindMethods(component) {
|
|
|
697
587
|
for (var autoBindKey in component.__reactAutoBindMap) {
|
|
698
588
|
if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
|
|
699
589
|
var method = component.__reactAutoBindMap[autoBindKey];
|
|
700
|
-
component[autoBindKey] = bindAutoBindMethod(
|
|
701
|
-
component,
|
|
702
|
-
ReactErrorUtils.guard(
|
|
703
|
-
method,
|
|
704
|
-
component.constructor.displayName + '.' + autoBindKey
|
|
705
|
-
)
|
|
706
|
-
);
|
|
590
|
+
component[autoBindKey] = bindAutoBindMethod(component, ReactErrorUtils.guard(method, component.constructor.displayName + '.' + autoBindKey));
|
|
707
591
|
}
|
|
708
592
|
}
|
|
709
593
|
}
|
|
710
594
|
|
|
711
595
|
var typeDeprecationDescriptor = {
|
|
712
596
|
enumerable: false,
|
|
713
|
-
get: function() {
|
|
597
|
+
get: function () {
|
|
714
598
|
var displayName = this.displayName || this.name || 'Component';
|
|
715
|
-
|
|
716
|
-
false,
|
|
717
|
-
'%s.type is deprecated. Use %s directly to access the class.',
|
|
718
|
-
displayName,
|
|
719
|
-
displayName
|
|
720
|
-
) : null);
|
|
599
|
+
'production' !== process.env.NODE_ENV ? warning(false, '%s.type is deprecated. Use %s directly to access the class.', displayName, displayName) : undefined;
|
|
721
600
|
Object.defineProperty(this, 'type', {
|
|
722
601
|
value: this
|
|
723
602
|
});
|
|
@@ -735,7 +614,7 @@ var ReactClassMixin = {
|
|
|
735
614
|
* TODO: This will be deprecated because state should always keep a consistent
|
|
736
615
|
* type signature and the only use case for this, is to avoid that.
|
|
737
616
|
*/
|
|
738
|
-
replaceState: function(newState, callback) {
|
|
617
|
+
replaceState: function (newState, callback) {
|
|
739
618
|
ReactUpdateQueue.enqueueReplaceState(this, newState);
|
|
740
619
|
if (callback) {
|
|
741
620
|
ReactUpdateQueue.enqueueCallback(this, callback);
|
|
@@ -748,27 +627,20 @@ var ReactClassMixin = {
|
|
|
748
627
|
* @protected
|
|
749
628
|
* @final
|
|
750
629
|
*/
|
|
751
|
-
isMounted: function() {
|
|
752
|
-
if (
|
|
630
|
+
isMounted: function () {
|
|
631
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
753
632
|
var owner = ReactCurrentOwner.current;
|
|
754
633
|
if (owner !== null) {
|
|
755
|
-
|
|
756
|
-
owner._warnedAboutRefsInRender,
|
|
757
|
-
'%s is accessing isMounted inside its render() function. ' +
|
|
758
|
-
'render() should be a pure function of props and state. It should ' +
|
|
759
|
-
'never access something that requires stale data from the previous ' +
|
|
760
|
-
'render, such as refs. Move this logic to componentDidMount and ' +
|
|
761
|
-
'componentDidUpdate instead.',
|
|
762
|
-
owner.getName() || 'A component'
|
|
763
|
-
) : null);
|
|
634
|
+
'production' !== process.env.NODE_ENV ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
|
|
764
635
|
owner._warnedAboutRefsInRender = true;
|
|
765
636
|
}
|
|
766
637
|
}
|
|
767
638
|
var internalInstance = ReactInstanceMap.get(this);
|
|
768
|
-
|
|
769
|
-
internalInstance
|
|
770
|
-
|
|
771
|
-
|
|
639
|
+
if (internalInstance) {
|
|
640
|
+
return internalInstance !== ReactLifeCycle.currentlyMountingInstance;
|
|
641
|
+
} else {
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
772
644
|
},
|
|
773
645
|
|
|
774
646
|
/**
|
|
@@ -780,7 +652,7 @@ var ReactClassMixin = {
|
|
|
780
652
|
* @public
|
|
781
653
|
* @deprecated
|
|
782
654
|
*/
|
|
783
|
-
setProps: function(partialProps, callback) {
|
|
655
|
+
setProps: function (partialProps, callback) {
|
|
784
656
|
ReactUpdateQueue.enqueueSetProps(this, partialProps);
|
|
785
657
|
if (callback) {
|
|
786
658
|
ReactUpdateQueue.enqueueCallback(this, callback);
|
|
@@ -796,7 +668,7 @@ var ReactClassMixin = {
|
|
|
796
668
|
* @public
|
|
797
669
|
* @deprecated
|
|
798
670
|
*/
|
|
799
|
-
replaceProps: function(newProps, callback) {
|
|
671
|
+
replaceProps: function (newProps, callback) {
|
|
800
672
|
ReactUpdateQueue.enqueueReplaceProps(this, newProps);
|
|
801
673
|
if (callback) {
|
|
802
674
|
ReactUpdateQueue.enqueueCallback(this, callback);
|
|
@@ -804,12 +676,8 @@ var ReactClassMixin = {
|
|
|
804
676
|
}
|
|
805
677
|
};
|
|
806
678
|
|
|
807
|
-
var ReactClassComponent = function() {};
|
|
808
|
-
assign(
|
|
809
|
-
ReactClassComponent.prototype,
|
|
810
|
-
ReactComponent.prototype,
|
|
811
|
-
ReactClassMixin
|
|
812
|
-
);
|
|
679
|
+
var ReactClassComponent = function () {};
|
|
680
|
+
assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
|
|
813
681
|
|
|
814
682
|
/**
|
|
815
683
|
* Module for creating composite components.
|
|
@@ -825,17 +693,13 @@ var ReactClass = {
|
|
|
825
693
|
* @return {function} Component constructor function.
|
|
826
694
|
* @public
|
|
827
695
|
*/
|
|
828
|
-
createClass: function(spec) {
|
|
829
|
-
var Constructor = function(props, context) {
|
|
696
|
+
createClass: function (spec) {
|
|
697
|
+
var Constructor = function (props, context) {
|
|
830
698
|
// This constructor is overridden by mocks. The argument is used
|
|
831
699
|
// by mocks to assert on what gets mounted.
|
|
832
700
|
|
|
833
|
-
if (
|
|
834
|
-
|
|
835
|
-
this instanceof Constructor,
|
|
836
|
-
'Something is calling a React component directly. Use a factory or ' +
|
|
837
|
-
'JSX instead. See: http://fb.me/react-legacyfactory'
|
|
838
|
-
) : null);
|
|
701
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
702
|
+
'production' !== process.env.NODE_ENV ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined;
|
|
839
703
|
}
|
|
840
704
|
|
|
841
705
|
// Wire up auto-binding
|
|
@@ -851,38 +715,31 @@ var ReactClass = {
|
|
|
851
715
|
// getInitialState and componentWillMount methods for initialization.
|
|
852
716
|
|
|
853
717
|
var initialState = this.getInitialState ? this.getInitialState() : null;
|
|
854
|
-
if (
|
|
718
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
855
719
|
// We allow auto-mocks to proceed as if they're returning null.
|
|
856
|
-
if (typeof initialState === 'undefined' &&
|
|
857
|
-
this.getInitialState._isMockFunction) {
|
|
720
|
+
if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) {
|
|
858
721
|
// This is probably bad practice. Consider warning here and
|
|
859
722
|
// deprecating this convenience.
|
|
860
723
|
initialState = null;
|
|
861
724
|
}
|
|
862
725
|
}
|
|
863
|
-
(
|
|
864
|
-
typeof initialState === 'object' && !Array.isArray(initialState),
|
|
865
|
-
'%s.getInitialState(): must return an object or null',
|
|
866
|
-
Constructor.displayName || 'ReactCompositeComponent'
|
|
867
|
-
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
|
|
726
|
+
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined;
|
|
868
727
|
|
|
869
728
|
this.state = initialState;
|
|
870
729
|
};
|
|
871
730
|
Constructor.prototype = new ReactClassComponent();
|
|
872
731
|
Constructor.prototype.constructor = Constructor;
|
|
873
732
|
|
|
874
|
-
injectedMixins.forEach(
|
|
875
|
-
mixSpecIntoComponent.bind(null, Constructor)
|
|
876
|
-
);
|
|
733
|
+
injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
|
|
877
734
|
|
|
878
735
|
mixSpecIntoComponent(Constructor, spec);
|
|
879
736
|
|
|
880
|
-
// Initialize the defaultProps property after all mixins have been merged
|
|
737
|
+
// Initialize the defaultProps property after all mixins have been merged.
|
|
881
738
|
if (Constructor.getDefaultProps) {
|
|
882
739
|
Constructor.defaultProps = Constructor.getDefaultProps();
|
|
883
740
|
}
|
|
884
741
|
|
|
885
|
-
if (
|
|
742
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
886
743
|
// This is a tag to indicate that the use of these method names is ok,
|
|
887
744
|
// since it's used with createClass. If it's not, then it's likely a
|
|
888
745
|
// mistake so we'll warn you to use the static property, property
|
|
@@ -895,20 +752,10 @@ var ReactClass = {
|
|
|
895
752
|
}
|
|
896
753
|
}
|
|
897
754
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
904
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
905
|
-
!Constructor.prototype.componentShouldUpdate,
|
|
906
|
-
'%s has a method called ' +
|
|
907
|
-
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
|
|
908
|
-
'The name is phrased as a question because the function is ' +
|
|
909
|
-
'expected to return a value.',
|
|
910
|
-
spec.displayName || 'A component'
|
|
911
|
-
) : null);
|
|
755
|
+
!Constructor.prototype.render ? 'production' !== process.env.NODE_ENV ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : undefined;
|
|
756
|
+
|
|
757
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
758
|
+
'production' !== process.env.NODE_ENV ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : undefined;
|
|
912
759
|
}
|
|
913
760
|
|
|
914
761
|
// Reduce time spent doing lookups by setting these on the prototype.
|
|
@@ -920,19 +767,17 @@ var ReactClass = {
|
|
|
920
767
|
|
|
921
768
|
// Legacy hook
|
|
922
769
|
Constructor.type = Constructor;
|
|
923
|
-
if (
|
|
770
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
924
771
|
try {
|
|
925
772
|
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
|
|
926
|
-
} catch (x) {
|
|
927
|
-
// IE will fail on defineProperty (es5-shim/sham too)
|
|
928
|
-
}
|
|
773
|
+
} catch (x) {}
|
|
929
774
|
}
|
|
930
775
|
|
|
931
776
|
return Constructor;
|
|
932
777
|
},
|
|
933
778
|
|
|
934
779
|
injection: {
|
|
935
|
-
injectMixin: function(mixin) {
|
|
780
|
+
injectMixin: function (mixin) {
|
|
936
781
|
injectedMixins.push(mixin);
|
|
937
782
|
}
|
|
938
783
|
}
|
|
@@ -940,3 +785,5 @@ var ReactClass = {
|
|
|
940
785
|
};
|
|
941
786
|
|
|
942
787
|
module.exports = ReactClass;
|
|
788
|
+
|
|
789
|
+
// IE will fail on defineProperty (es5-shim/sham too)
|