react 0.14.0-alpha3 → 0.14.0-rc1
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 +5 -2
- package/addons.js +8 -3
- package/dist/react-dom.js +42 -0
- package/dist/react-dom.min.js +12 -0
- package/dist/react-with-addons.js +6076 -5337
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +5445 -4839
- package/dist/react.min.js +6 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +18 -3
- package/lib/CSSPropertyOperations.js +22 -14
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +18 -15
- package/lib/DOMChildrenOperations.js +17 -7
- package/lib/DOMProperty.js +82 -117
- package/lib/DOMPropertyOperations.js +84 -33
- package/lib/Danger.js +21 -16
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +21 -13
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +17 -20
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +33 -42
- package/lib/EventPropagators.js +8 -8
- package/lib/FallbackCompositionState.js +9 -3
- package/lib/HTMLDOMPropertyConfig.js +19 -3
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +50 -38
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +15 -5
- package/lib/React.js +18 -7
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +35 -9
- package/lib/ReactCSSTransitionGroupChild.js +56 -30
- package/lib/ReactChildReconciler.js +24 -19
- package/lib/ReactChildren.js +75 -35
- package/lib/ReactClass.js +70 -87
- package/lib/ReactComponent.js +27 -20
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +117 -106
- package/lib/ReactDOM.js +74 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +441 -72
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
- package/lib/ReactDOMIDOperations.js +8 -66
- package/lib/ReactDOMInput.js +87 -99
- package/lib/ReactDOMOption.js +25 -44
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +5 -3
- package/lib/ReactDOMTextComponent.js +33 -20
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +23 -72
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -11
- package/lib/ReactElement.js +92 -107
- package/lib/ReactElementValidator.js +53 -173
- package/lib/ReactEmptyComponent.js +26 -62
- package/lib/ReactEmptyComponentRegistry.js +48 -0
- package/lib/ReactErrorUtils.js +45 -9
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +64 -12
- package/lib/ReactFragment.js +29 -115
- package/lib/ReactInjection.js +10 -12
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +15 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +196 -122
- package/lib/ReactMultiChild.js +119 -25
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -8
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +41 -12
- package/lib/ReactReconcileTransaction.js +12 -10
- package/lib/ReactReconciler.js +8 -11
- package/lib/ReactRef.js +15 -2
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +8 -7
- package/lib/ReactTestUtils.js +89 -64
- package/lib/ReactTransitionChildMapping.js +3 -6
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +60 -35
- package/lib/ReactUpdates.js +15 -18
- package/lib/{isTextNode.js → ReactVersion.js} +2 -13
- package/lib/ReactWithAddons.js +24 -17
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +25 -16
- package/lib/SimpleEventPlugin.js +200 -45
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +24 -8
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +3 -3
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +5 -5
- package/lib/SyntheticTouchEvent.js +4 -4
- package/lib/SyntheticUIEvent.js +4 -4
- package/lib/SyntheticWheelEvent.js +3 -3
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +17 -11
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +48 -0
- package/lib/findDOMNode.js +11 -12
- package/lib/flattenChildren.js +4 -4
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +27 -25
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +216 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +2 -2
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +12 -8
- package/lib/sliceChildren.js +34 -0
- package/lib/traverseAllChildren.js +21 -19
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +6 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +2 -0
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/dist/JSXTransformer.js +0 -17589
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- package/lib/ReactDOMClient.js +0 -85
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createFullPageComponent.js +0 -51
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -115
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/performance.js +0 -23
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -61
package/lib/ReactChildren.js
CHANGED
|
@@ -11,14 +11,19 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var PooledClass = require(
|
|
15
|
-
var
|
|
14
|
+
var PooledClass = require('./PooledClass');
|
|
15
|
+
var ReactElement = require('./ReactElement');
|
|
16
16
|
|
|
17
|
-
var
|
|
18
|
-
var
|
|
17
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
18
|
+
var traverseAllChildren = require('./traverseAllChildren');
|
|
19
19
|
|
|
20
20
|
var twoArgumentPooler = PooledClass.twoArgumentPooler;
|
|
21
|
-
var
|
|
21
|
+
var fourArgumentPooler = PooledClass.fourArgumentPooler;
|
|
22
|
+
|
|
23
|
+
var userProvidedKeyEscapeRegex = /\/(?!\/)/g;
|
|
24
|
+
function escapeUserProvidedKey(text) {
|
|
25
|
+
return ('' + text).replace(userProvidedKeyEscapeRegex, '//');
|
|
26
|
+
}
|
|
22
27
|
|
|
23
28
|
/**
|
|
24
29
|
* PooledClass representing the bookkeeping associated with performing a child
|
|
@@ -33,11 +38,18 @@ function ForEachBookKeeping(forEachFunction, forEachContext) {
|
|
|
33
38
|
this.context = forEachContext;
|
|
34
39
|
this.count = 0;
|
|
35
40
|
}
|
|
41
|
+
ForEachBookKeeping.prototype.destructor = function () {
|
|
42
|
+
this.func = null;
|
|
43
|
+
this.context = null;
|
|
44
|
+
this.count = 0;
|
|
45
|
+
};
|
|
36
46
|
PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
|
|
37
47
|
|
|
38
|
-
function forEachSingleChild(
|
|
39
|
-
var
|
|
40
|
-
|
|
48
|
+
function forEachSingleChild(bookKeeping, child, name) {
|
|
49
|
+
var func = bookKeeping.func;
|
|
50
|
+
var context = bookKeeping.context;
|
|
51
|
+
|
|
52
|
+
func.call(context, child, bookKeeping.count++);
|
|
41
53
|
}
|
|
42
54
|
|
|
43
55
|
/**
|
|
@@ -47,14 +59,13 @@ function forEachSingleChild(traverseContext, child, name) {
|
|
|
47
59
|
* leaf child.
|
|
48
60
|
*
|
|
49
61
|
* @param {?*} children Children tree container.
|
|
50
|
-
* @param {function(*, int)} forEachFunc
|
|
62
|
+
* @param {function(*, int)} forEachFunc
|
|
51
63
|
* @param {*} forEachContext Context for forEachContext.
|
|
52
64
|
*/
|
|
53
65
|
function forEachChildren(children, forEachFunc, forEachContext) {
|
|
54
66
|
if (children == null) {
|
|
55
67
|
return children;
|
|
56
68
|
}
|
|
57
|
-
|
|
58
69
|
var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
|
|
59
70
|
traverseAllChildren(children, forEachSingleChild, traverseContext);
|
|
60
71
|
ForEachBookKeeping.release(traverseContext);
|
|
@@ -69,27 +80,50 @@ function forEachChildren(children, forEachFunc, forEachContext) {
|
|
|
69
80
|
* @param {!function} mapFunction Function to perform mapping with.
|
|
70
81
|
* @param {?*} mapContext Context to perform mapping with.
|
|
71
82
|
*/
|
|
72
|
-
function MapBookKeeping(mapResult, mapFunction, mapContext) {
|
|
83
|
+
function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
|
|
73
84
|
this.result = mapResult;
|
|
85
|
+
this.keyPrefix = keyPrefix;
|
|
74
86
|
this.func = mapFunction;
|
|
75
87
|
this.context = mapContext;
|
|
76
88
|
this.count = 0;
|
|
77
89
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
MapBookKeeping.prototype.destructor = function () {
|
|
91
|
+
this.result = null;
|
|
92
|
+
this.keyPrefix = null;
|
|
93
|
+
this.func = null;
|
|
94
|
+
this.context = null;
|
|
95
|
+
this.count = 0;
|
|
96
|
+
};
|
|
97
|
+
PooledClass.addPoolingTo(MapBookKeeping, fourArgumentPooler);
|
|
98
|
+
|
|
99
|
+
function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
|
100
|
+
var result = bookKeeping.result;
|
|
101
|
+
var keyPrefix = bookKeeping.keyPrefix;
|
|
102
|
+
var func = bookKeeping.func;
|
|
103
|
+
var context = bookKeeping.context;
|
|
104
|
+
|
|
105
|
+
var mappedChild = func.call(context, child, bookKeeping.count++);
|
|
106
|
+
if (Array.isArray(mappedChild)) {
|
|
107
|
+
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
|
|
108
|
+
} else if (mappedChild != null) {
|
|
109
|
+
if (ReactElement.isValidElement(mappedChild)) {
|
|
110
|
+
mappedChild = ReactElement.cloneAndReplaceKey(mappedChild,
|
|
111
|
+
// Keep both the (mapped) and old keys if they differ, just as
|
|
112
|
+
// traverseAllChildren used to do for objects as children
|
|
113
|
+
keyPrefix + (mappedChild !== child ? escapeUserProvidedKey(mappedChild.key || '') + '/' : '') + childKey);
|
|
114
|
+
}
|
|
115
|
+
result.push(mappedChild);
|
|
87
116
|
}
|
|
117
|
+
}
|
|
88
118
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
119
|
+
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
|
120
|
+
var escapedPrefix = '';
|
|
121
|
+
if (prefix != null) {
|
|
122
|
+
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
|
|
92
123
|
}
|
|
124
|
+
var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
|
|
125
|
+
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
|
126
|
+
MapBookKeeping.release(traverseContext);
|
|
93
127
|
}
|
|
94
128
|
|
|
95
129
|
/**
|
|
@@ -98,24 +132,18 @@ function mapSingleChildIntoContext(traverseContext, child, name) {
|
|
|
98
132
|
* The provided mapFunction(child, key, index) will be called for each
|
|
99
133
|
* leaf child.
|
|
100
134
|
*
|
|
101
|
-
* TODO: This may likely break any calls to `ReactChildren.map` that were
|
|
102
|
-
* previously relying on the fact that we guarded against null children.
|
|
103
|
-
*
|
|
104
135
|
* @param {?*} children Children tree container.
|
|
105
|
-
* @param {function(*, int)}
|
|
106
|
-
* @param {*}
|
|
136
|
+
* @param {function(*, int)} func The map function.
|
|
137
|
+
* @param {*} context Context for mapFunction.
|
|
107
138
|
* @return {object} Object containing the ordered map of results.
|
|
108
139
|
*/
|
|
109
140
|
function mapChildren(children, func, context) {
|
|
110
141
|
if (children == null) {
|
|
111
142
|
return children;
|
|
112
143
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
|
117
|
-
MapBookKeeping.release(traverseContext);
|
|
118
|
-
return ReactFragment.create(mapResult);
|
|
144
|
+
var result = [];
|
|
145
|
+
mapIntoWithKeyPrefixInternal(children, result, null, func, context);
|
|
146
|
+
return result;
|
|
119
147
|
}
|
|
120
148
|
|
|
121
149
|
function forEachSingleChildDummy(traverseContext, child, name) {
|
|
@@ -133,10 +161,22 @@ function countChildren(children, context) {
|
|
|
133
161
|
return traverseAllChildren(children, forEachSingleChildDummy, null);
|
|
134
162
|
}
|
|
135
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Flatten a children object (typically specified as `props.children`) and
|
|
166
|
+
* return an array with appropriately re-keyed children.
|
|
167
|
+
*/
|
|
168
|
+
function toArray(children) {
|
|
169
|
+
var result = [];
|
|
170
|
+
mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
|
|
136
174
|
var ReactChildren = {
|
|
137
175
|
forEach: forEachChildren,
|
|
138
176
|
map: mapChildren,
|
|
139
|
-
|
|
177
|
+
mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
|
|
178
|
+
count: countChildren,
|
|
179
|
+
toArray: toArray
|
|
140
180
|
};
|
|
141
181
|
|
|
142
182
|
module.exports = ReactChildren;
|
package/lib/ReactClass.js
CHANGED
|
@@ -11,21 +11,18 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactComponent = require(
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var keyMirror = require("./keyMirror");
|
|
27
|
-
var keyOf = require("./keyOf");
|
|
28
|
-
var warning = require("./warning");
|
|
14
|
+
var ReactComponent = require('./ReactComponent');
|
|
15
|
+
var ReactElement = require('./ReactElement');
|
|
16
|
+
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
17
|
+
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
18
|
+
var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
|
|
19
|
+
|
|
20
|
+
var assign = require('./Object.assign');
|
|
21
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
22
|
+
var invariant = require('fbjs/lib/invariant');
|
|
23
|
+
var keyMirror = require('fbjs/lib/keyMirror');
|
|
24
|
+
var keyOf = require('fbjs/lib/keyOf');
|
|
25
|
+
var warning = require('fbjs/lib/warning');
|
|
29
26
|
|
|
30
27
|
var MIXINS_KEY = keyOf({ mixins: null });
|
|
31
28
|
|
|
@@ -56,6 +53,14 @@ var SpecPolicy = keyMirror({
|
|
|
56
53
|
|
|
57
54
|
var injectedMixins = [];
|
|
58
55
|
|
|
56
|
+
var warnedSetProps = false;
|
|
57
|
+
function warnSetProps() {
|
|
58
|
+
if (!warnedSetProps) {
|
|
59
|
+
warnedSetProps = true;
|
|
60
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call render again at the top level.') : undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
/**
|
|
60
65
|
* Composite components are higher-level components that compose other composite
|
|
61
66
|
* or native components.
|
|
@@ -322,13 +327,13 @@ var RESERVED_SPEC_KEYS = {
|
|
|
322
327
|
}
|
|
323
328
|
},
|
|
324
329
|
childContextTypes: function (Constructor, childContextTypes) {
|
|
325
|
-
if (
|
|
330
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
326
331
|
validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
|
|
327
332
|
}
|
|
328
333
|
Constructor.childContextTypes = assign({}, Constructor.childContextTypes, childContextTypes);
|
|
329
334
|
},
|
|
330
335
|
contextTypes: function (Constructor, contextTypes) {
|
|
331
|
-
if (
|
|
336
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
332
337
|
validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
|
|
333
338
|
}
|
|
334
339
|
Constructor.contextTypes = assign({}, Constructor.contextTypes, contextTypes);
|
|
@@ -345,22 +350,23 @@ var RESERVED_SPEC_KEYS = {
|
|
|
345
350
|
}
|
|
346
351
|
},
|
|
347
352
|
propTypes: function (Constructor, propTypes) {
|
|
348
|
-
if (
|
|
353
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
349
354
|
validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
|
|
350
355
|
}
|
|
351
356
|
Constructor.propTypes = assign({}, Constructor.propTypes, propTypes);
|
|
352
357
|
},
|
|
353
358
|
statics: function (Constructor, statics) {
|
|
354
359
|
mixStaticSpecIntoComponent(Constructor, statics);
|
|
355
|
-
}
|
|
356
|
-
};
|
|
360
|
+
},
|
|
361
|
+
autobind: function () {} };
|
|
357
362
|
|
|
363
|
+
// noop
|
|
358
364
|
function validateTypeDef(Constructor, typeDef, location) {
|
|
359
365
|
for (var propName in typeDef) {
|
|
360
366
|
if (typeDef.hasOwnProperty(propName)) {
|
|
361
367
|
// use a warning instead of an invariant so components
|
|
362
368
|
// don't show up in prod but not in __DEV__
|
|
363
|
-
|
|
369
|
+
process.env.NODE_ENV !== 'production' ? 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;
|
|
364
370
|
}
|
|
365
371
|
}
|
|
366
372
|
}
|
|
@@ -370,12 +376,12 @@ function validateMethodOverride(proto, name) {
|
|
|
370
376
|
|
|
371
377
|
// Disallow overriding of base class methods unless explicitly allowed.
|
|
372
378
|
if (ReactClassMixin.hasOwnProperty(name)) {
|
|
373
|
-
!(specPolicy === SpecPolicy.OVERRIDE_BASE) ?
|
|
379
|
+
!(specPolicy === SpecPolicy.OVERRIDE_BASE) ? process.env.NODE_ENV !== 'production' ? 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;
|
|
374
380
|
}
|
|
375
381
|
|
|
376
382
|
// Disallow defining methods more than once unless explicitly allowed.
|
|
377
383
|
if (proto.hasOwnProperty(name)) {
|
|
378
|
-
!(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ?
|
|
384
|
+
!(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? process.env.NODE_ENV !== 'production' ? 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;
|
|
379
385
|
}
|
|
380
386
|
}
|
|
381
387
|
|
|
@@ -388,8 +394,8 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
388
394
|
return;
|
|
389
395
|
}
|
|
390
396
|
|
|
391
|
-
!(typeof spec !== 'function') ?
|
|
392
|
-
!!ReactElement.isValidElement(spec) ?
|
|
397
|
+
!(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
|
|
398
|
+
!!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
|
|
393
399
|
|
|
394
400
|
var proto = Constructor.prototype;
|
|
395
401
|
|
|
@@ -423,7 +429,7 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
423
429
|
var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
|
|
424
430
|
var isAlreadyDefined = proto.hasOwnProperty(name);
|
|
425
431
|
var isFunction = typeof property === 'function';
|
|
426
|
-
var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined;
|
|
432
|
+
var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
|
|
427
433
|
|
|
428
434
|
if (shouldAutoBind) {
|
|
429
435
|
if (!proto.__reactAutoBindMap) {
|
|
@@ -436,7 +442,7 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
436
442
|
var specPolicy = ReactClassInterface[name];
|
|
437
443
|
|
|
438
444
|
// These cases should already be caught by validateMethodOverride.
|
|
439
|
-
!(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ?
|
|
445
|
+
!(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(false) : undefined;
|
|
440
446
|
|
|
441
447
|
// For methods which are defined more than once, call the existing
|
|
442
448
|
// methods before calling the new property, merging if appropriate.
|
|
@@ -447,7 +453,7 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
447
453
|
}
|
|
448
454
|
} else {
|
|
449
455
|
proto[name] = property;
|
|
450
|
-
if (
|
|
456
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
451
457
|
// Add verbose displayName to the function, which helps when looking
|
|
452
458
|
// at profiling tools.
|
|
453
459
|
if (typeof property === 'function' && spec.displayName) {
|
|
@@ -471,10 +477,10 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
471
477
|
}
|
|
472
478
|
|
|
473
479
|
var isReserved = (name in RESERVED_SPEC_KEYS);
|
|
474
|
-
!!isReserved ?
|
|
480
|
+
!!isReserved ? process.env.NODE_ENV !== 'production' ? 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
481
|
|
|
476
482
|
var isInherited = (name in Constructor);
|
|
477
|
-
!!isInherited ?
|
|
483
|
+
!!isInherited ? process.env.NODE_ENV !== 'production' ? 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;
|
|
478
484
|
Constructor[name] = property;
|
|
479
485
|
}
|
|
480
486
|
}
|
|
@@ -487,11 +493,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
487
493
|
* @return {object} one after it has been mutated to contain everything in two.
|
|
488
494
|
*/
|
|
489
495
|
function mergeIntoWithNoDuplicateKeys(one, two) {
|
|
490
|
-
!(one && two && typeof one === 'object' && typeof two === 'object') ?
|
|
496
|
+
!(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : undefined;
|
|
491
497
|
|
|
492
498
|
for (var key in two) {
|
|
493
499
|
if (two.hasOwnProperty(key)) {
|
|
494
|
-
!(one[key] === undefined) ?
|
|
500
|
+
!(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? 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;
|
|
495
501
|
one[key] = two[key];
|
|
496
502
|
}
|
|
497
503
|
}
|
|
@@ -546,7 +552,7 @@ function createChainedFunction(one, two) {
|
|
|
546
552
|
*/
|
|
547
553
|
function bindAutoBindMethod(component, method) {
|
|
548
554
|
var boundMethod = method.bind(component);
|
|
549
|
-
if (
|
|
555
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
550
556
|
boundMethod.__reactBoundContext = component;
|
|
551
557
|
boundMethod.__reactBoundMethod = method;
|
|
552
558
|
boundMethod.__reactBoundArguments = null;
|
|
@@ -562,9 +568,9 @@ function bindAutoBindMethod(component, method) {
|
|
|
562
568
|
// ignore the value of "this" that the user is trying to use, so
|
|
563
569
|
// let's warn.
|
|
564
570
|
if (newThis !== component && newThis !== null) {
|
|
565
|
-
|
|
571
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : undefined;
|
|
566
572
|
} else if (!args.length) {
|
|
567
|
-
|
|
573
|
+
process.env.NODE_ENV !== 'production' ? 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;
|
|
568
574
|
return boundMethod;
|
|
569
575
|
}
|
|
570
576
|
var reboundMethod = _bind.apply(boundMethod, arguments);
|
|
@@ -587,23 +593,11 @@ function bindAutoBindMethods(component) {
|
|
|
587
593
|
for (var autoBindKey in component.__reactAutoBindMap) {
|
|
588
594
|
if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
|
|
589
595
|
var method = component.__reactAutoBindMap[autoBindKey];
|
|
590
|
-
component[autoBindKey] = bindAutoBindMethod(component,
|
|
596
|
+
component[autoBindKey] = bindAutoBindMethod(component, method);
|
|
591
597
|
}
|
|
592
598
|
}
|
|
593
599
|
}
|
|
594
600
|
|
|
595
|
-
var typeDeprecationDescriptor = {
|
|
596
|
-
enumerable: false,
|
|
597
|
-
get: function () {
|
|
598
|
-
var displayName = this.displayName || this.name || 'Component';
|
|
599
|
-
'production' !== process.env.NODE_ENV ? warning(false, '%s.type is deprecated. Use %s directly to access the class.', displayName, displayName) : undefined;
|
|
600
|
-
Object.defineProperty(this, 'type', {
|
|
601
|
-
value: this
|
|
602
|
-
});
|
|
603
|
-
return this;
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
|
|
607
601
|
/**
|
|
608
602
|
* Add more to the ReactClass base class. These are all legacy features and
|
|
609
603
|
* therefore not already part of the modern ReactComponent.
|
|
@@ -615,9 +609,9 @@ var ReactClassMixin = {
|
|
|
615
609
|
* type signature and the only use case for this, is to avoid that.
|
|
616
610
|
*/
|
|
617
611
|
replaceState: function (newState, callback) {
|
|
618
|
-
|
|
612
|
+
this.updater.enqueueReplaceState(this, newState);
|
|
619
613
|
if (callback) {
|
|
620
|
-
|
|
614
|
+
this.updater.enqueueCallback(this, callback);
|
|
621
615
|
}
|
|
622
616
|
},
|
|
623
617
|
|
|
@@ -628,19 +622,7 @@ var ReactClassMixin = {
|
|
|
628
622
|
* @final
|
|
629
623
|
*/
|
|
630
624
|
isMounted: function () {
|
|
631
|
-
|
|
632
|
-
var owner = ReactCurrentOwner.current;
|
|
633
|
-
if (owner !== 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;
|
|
635
|
-
owner._warnedAboutRefsInRender = true;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
var internalInstance = ReactInstanceMap.get(this);
|
|
639
|
-
if (internalInstance) {
|
|
640
|
-
return internalInstance !== ReactLifeCycle.currentlyMountingInstance;
|
|
641
|
-
} else {
|
|
642
|
-
return false;
|
|
643
|
-
}
|
|
625
|
+
return this.updater.isMounted(this);
|
|
644
626
|
},
|
|
645
627
|
|
|
646
628
|
/**
|
|
@@ -653,9 +635,12 @@ var ReactClassMixin = {
|
|
|
653
635
|
* @deprecated
|
|
654
636
|
*/
|
|
655
637
|
setProps: function (partialProps, callback) {
|
|
656
|
-
|
|
638
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
639
|
+
warnSetProps();
|
|
640
|
+
}
|
|
641
|
+
this.updater.enqueueSetProps(this, partialProps);
|
|
657
642
|
if (callback) {
|
|
658
|
-
|
|
643
|
+
this.updater.enqueueCallback(this, callback);
|
|
659
644
|
}
|
|
660
645
|
},
|
|
661
646
|
|
|
@@ -669,9 +654,12 @@ var ReactClassMixin = {
|
|
|
669
654
|
* @deprecated
|
|
670
655
|
*/
|
|
671
656
|
replaceProps: function (newProps, callback) {
|
|
672
|
-
|
|
657
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
658
|
+
warnSetProps();
|
|
659
|
+
}
|
|
660
|
+
this.updater.enqueueReplaceProps(this, newProps);
|
|
673
661
|
if (callback) {
|
|
674
|
-
|
|
662
|
+
this.updater.enqueueCallback(this, callback);
|
|
675
663
|
}
|
|
676
664
|
}
|
|
677
665
|
};
|
|
@@ -694,12 +682,12 @@ var ReactClass = {
|
|
|
694
682
|
* @public
|
|
695
683
|
*/
|
|
696
684
|
createClass: function (spec) {
|
|
697
|
-
var Constructor = function (props, context) {
|
|
685
|
+
var Constructor = function (props, context, updater) {
|
|
698
686
|
// This constructor is overridden by mocks. The argument is used
|
|
699
687
|
// by mocks to assert on what gets mounted.
|
|
700
688
|
|
|
701
|
-
if (
|
|
702
|
-
|
|
689
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
690
|
+
process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined;
|
|
703
691
|
}
|
|
704
692
|
|
|
705
693
|
// Wire up auto-binding
|
|
@@ -709,13 +697,16 @@ var ReactClass = {
|
|
|
709
697
|
|
|
710
698
|
this.props = props;
|
|
711
699
|
this.context = context;
|
|
700
|
+
this.refs = emptyObject;
|
|
701
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
702
|
+
|
|
712
703
|
this.state = null;
|
|
713
704
|
|
|
714
705
|
// ReactClasses doesn't have constructors. Instead, they use the
|
|
715
706
|
// getInitialState and componentWillMount methods for initialization.
|
|
716
707
|
|
|
717
708
|
var initialState = this.getInitialState ? this.getInitialState() : null;
|
|
718
|
-
if (
|
|
709
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
719
710
|
// We allow auto-mocks to proceed as if they're returning null.
|
|
720
711
|
if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) {
|
|
721
712
|
// This is probably bad practice. Consider warning here and
|
|
@@ -723,12 +714,13 @@ var ReactClass = {
|
|
|
723
714
|
initialState = null;
|
|
724
715
|
}
|
|
725
716
|
}
|
|
726
|
-
!(typeof initialState === 'object' && !Array.isArray(initialState)) ?
|
|
717
|
+
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined;
|
|
727
718
|
|
|
728
719
|
this.state = initialState;
|
|
729
720
|
};
|
|
730
721
|
Constructor.prototype = new ReactClassComponent();
|
|
731
722
|
Constructor.prototype.constructor = Constructor;
|
|
723
|
+
Constructor.isReactClass = {};
|
|
732
724
|
|
|
733
725
|
injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
|
|
734
726
|
|
|
@@ -739,7 +731,7 @@ var ReactClass = {
|
|
|
739
731
|
Constructor.defaultProps = Constructor.getDefaultProps();
|
|
740
732
|
}
|
|
741
733
|
|
|
742
|
-
if (
|
|
734
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
743
735
|
// This is a tag to indicate that the use of these method names is ok,
|
|
744
736
|
// since it's used with createClass. If it's not, then it's likely a
|
|
745
737
|
// mistake so we'll warn you to use the static property, property
|
|
@@ -752,10 +744,11 @@ var ReactClass = {
|
|
|
752
744
|
}
|
|
753
745
|
}
|
|
754
746
|
|
|
755
|
-
!Constructor.prototype.render ?
|
|
747
|
+
!Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : undefined;
|
|
756
748
|
|
|
757
|
-
if (
|
|
758
|
-
|
|
749
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
750
|
+
process.env.NODE_ENV !== 'production' ? 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;
|
|
751
|
+
process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : undefined;
|
|
759
752
|
}
|
|
760
753
|
|
|
761
754
|
// Reduce time spent doing lookups by setting these on the prototype.
|
|
@@ -765,14 +758,6 @@ var ReactClass = {
|
|
|
765
758
|
}
|
|
766
759
|
}
|
|
767
760
|
|
|
768
|
-
// Legacy hook
|
|
769
|
-
Constructor.type = Constructor;
|
|
770
|
-
if ('production' !== process.env.NODE_ENV) {
|
|
771
|
-
try {
|
|
772
|
-
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
|
|
773
|
-
} catch (x) {}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
761
|
return Constructor;
|
|
777
762
|
},
|
|
778
763
|
|
|
@@ -784,6 +769,4 @@ var ReactClass = {
|
|
|
784
769
|
|
|
785
770
|
};
|
|
786
771
|
|
|
787
|
-
module.exports = ReactClass;
|
|
788
|
-
|
|
789
|
-
// IE will fail on defineProperty (es5-shim/sham too)
|
|
772
|
+
module.exports = ReactClass;
|