react 0.14.0-alpha2 → 0.14.0-beta3
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 +6 -3
- package/dist/JSXTransformer.js +634 -274
- package/dist/react-with-addons.js +5350 -4954
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4777 -4408
- 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 +3 -0
- package/lib/CSSPropertyOperations.js +13 -13
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +16 -14
- package/lib/DOMChildrenOperations.js +10 -6
- package/lib/DOMProperty.js +82 -117
- package/lib/DOMPropertyOperations.js +78 -33
- package/lib/Danger.js +14 -14
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +8 -8
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +13 -13
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +17 -17
- package/lib/EventPropagators.js +7 -7
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +13 -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 +14 -2
- package/lib/React.js +6 -6
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +16 -5
- package/lib/ReactCSSTransitionGroupChild.js +20 -11
- package/lib/ReactChildReconciler.js +25 -18
- package/lib/ReactChildren.js +9 -9
- package/lib/ReactClass.js +65 -83
- package/lib/ReactComponent.js +22 -17
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +80 -111
- package/lib/ReactDOM.js +72 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +378 -56
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/ReactDOMIDOperations.js +23 -23
- package/lib/ReactDOMInput.js +83 -99
- package/lib/ReactDOMOption.js +25 -45
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +2 -2
- package/lib/ReactDOMTextComponent.js +11 -11
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +24 -71
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -9
- package/lib/ReactElement.js +22 -83
- package/lib/ReactElementValidator.js +48 -117
- package/lib/ReactEmptyComponent.js +4 -4
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +57 -12
- package/lib/ReactFragment.js +22 -17
- package/lib/ReactInjection.js +11 -11
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +11 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +88 -88
- package/lib/ReactMultiChild.js +83 -22
- 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 +49 -11
- package/lib/ReactReconcileTransaction.js +8 -8
- package/lib/ReactReconciler.js +18 -20
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +7 -7
- package/lib/ReactTestUtils.js +80 -58
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +61 -36
- package/lib/ReactUpdates.js +14 -17
- package/lib/ReactWithAddons.js +14 -16
- 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 +14 -15
- package/lib/SimpleEventPlugin.js +205 -29
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +9 -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 +16 -10
- 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 +47 -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 +24 -20
- 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 +210 -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/sliceChildren.js +51 -0
- package/lib/traverseAllChildren.js +15 -14
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +14 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +53 -1
- 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/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/emptyObject.js +0 -20
- 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/isTextNode.js +0 -25
- 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/ReactComponent.js
CHANGED
|
@@ -11,17 +11,22 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
|
|
15
15
|
|
|
16
|
-
var
|
|
17
|
-
var
|
|
16
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
17
|
+
var invariant = require('fbjs/lib/invariant');
|
|
18
|
+
var warning = require('fbjs/lib/warning');
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Base class helpers for the updating state of a component.
|
|
21
22
|
*/
|
|
22
|
-
function ReactComponent(props, context) {
|
|
23
|
+
function ReactComponent(props, context, updater) {
|
|
23
24
|
this.props = props;
|
|
24
25
|
this.context = context;
|
|
26
|
+
this.refs = emptyObject;
|
|
27
|
+
// We initialize the default updater but the real one gets injected by the
|
|
28
|
+
// renderer.
|
|
29
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
/**
|
|
@@ -50,13 +55,13 @@ function ReactComponent(props, context) {
|
|
|
50
55
|
* @protected
|
|
51
56
|
*/
|
|
52
57
|
ReactComponent.prototype.setState = function (partialState, callback) {
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
58
|
+
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.') : invariant(false) : undefined;
|
|
59
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
60
|
+
process.env.NODE_ENV !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : undefined;
|
|
56
61
|
}
|
|
57
|
-
|
|
62
|
+
this.updater.enqueueSetState(this, partialState);
|
|
58
63
|
if (callback) {
|
|
59
|
-
|
|
64
|
+
this.updater.enqueueCallback(this, callback);
|
|
60
65
|
}
|
|
61
66
|
};
|
|
62
67
|
|
|
@@ -75,9 +80,9 @@ ReactComponent.prototype.setState = function (partialState, callback) {
|
|
|
75
80
|
* @protected
|
|
76
81
|
*/
|
|
77
82
|
ReactComponent.prototype.forceUpdate = function (callback) {
|
|
78
|
-
|
|
83
|
+
this.updater.enqueueForceUpdate(this);
|
|
79
84
|
if (callback) {
|
|
80
|
-
|
|
85
|
+
this.updater.enqueueCallback(this, callback);
|
|
81
86
|
}
|
|
82
87
|
};
|
|
83
88
|
|
|
@@ -86,7 +91,7 @@ ReactComponent.prototype.forceUpdate = function (callback) {
|
|
|
86
91
|
* we would like to deprecate them, we're not going to move them over to this
|
|
87
92
|
* modern base class. Instead, we define a getter that warns if it's accessed.
|
|
88
93
|
*/
|
|
89
|
-
if (
|
|
94
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
90
95
|
var deprecatedAPIs = {
|
|
91
96
|
getDOMNode: ['getDOMNode', 'Use React.findDOMNode(component) instead.'],
|
|
92
97
|
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
@@ -98,11 +103,13 @@ if ('production' !== process.env.NODE_ENV) {
|
|
|
98
103
|
try {
|
|
99
104
|
Object.defineProperty(ReactComponent.prototype, methodName, {
|
|
100
105
|
get: function () {
|
|
101
|
-
|
|
106
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : undefined;
|
|
102
107
|
return undefined;
|
|
103
108
|
}
|
|
104
109
|
});
|
|
105
|
-
} catch (x) {
|
|
110
|
+
} catch (x) {
|
|
111
|
+
// IE will fail on defineProperty (es5-shim/sham too)
|
|
112
|
+
}
|
|
106
113
|
};
|
|
107
114
|
for (var fnName in deprecatedAPIs) {
|
|
108
115
|
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
@@ -111,6 +118,4 @@ if ('production' !== process.env.NODE_ENV) {
|
|
|
111
118
|
}
|
|
112
119
|
}
|
|
113
120
|
|
|
114
|
-
module.exports = ReactComponent;
|
|
115
|
-
|
|
116
|
-
// IE will fail on defineProperty (es5-shim/sham too)
|
|
121
|
+
module.exports = ReactComponent;
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactDOMIDOperations = require(
|
|
15
|
-
var ReactMount = require(
|
|
14
|
+
var ReactDOMIDOperations = require('./ReactDOMIDOperations');
|
|
15
|
+
var ReactMount = require('./ReactMount');
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Abstracts away all functionality of the reconciler that requires knowledge of
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var invariant = require(
|
|
14
|
+
var invariant = require('fbjs/lib/invariant');
|
|
15
15
|
|
|
16
16
|
var injected = false;
|
|
17
17
|
|
|
@@ -38,7 +38,7 @@ var ReactComponentEnvironment = {
|
|
|
38
38
|
|
|
39
39
|
injection: {
|
|
40
40
|
injectEnvironment: function (environment) {
|
|
41
|
-
|
|
41
|
+
!!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) : undefined;
|
|
42
42
|
ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
|
|
43
43
|
ReactComponentEnvironment.replaceNodeWithMarkupByID = environment.replaceNodeWithMarkupByID;
|
|
44
44
|
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
|
-
* @providesModule ReactComponentWithPureRenderMixin
|
|
10
|
-
*/
|
|
9
|
+
* @providesModule ReactComponentWithPureRenderMixin
|
|
10
|
+
*/
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var shallowCompare = require(
|
|
14
|
+
var shallowCompare = require('./shallowCompare');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* If your React component's render function is "pure", e.g. it will render the
|
|
@@ -11,25 +11,21 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactComponentEnvironment = require(
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
var emptyObject = require("./emptyObject");
|
|
30
|
-
var invariant = require("./invariant");
|
|
31
|
-
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
|
|
32
|
-
var warning = require("./warning");
|
|
14
|
+
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
|
|
15
|
+
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
16
|
+
var ReactElement = require('./ReactElement');
|
|
17
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
18
|
+
var ReactPerf = require('./ReactPerf');
|
|
19
|
+
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
20
|
+
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
21
|
+
var ReactReconciler = require('./ReactReconciler');
|
|
22
|
+
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
23
|
+
|
|
24
|
+
var assign = require('./Object.assign');
|
|
25
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
26
|
+
var invariant = require('fbjs/lib/invariant');
|
|
27
|
+
var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
|
|
28
|
+
var warning = require('fbjs/lib/warning');
|
|
33
29
|
|
|
34
30
|
function getDeclarationErrorAddendum(component) {
|
|
35
31
|
var owner = component._currentElement._owner || null;
|
|
@@ -104,7 +100,7 @@ var ReactCompositeComponentMixin = {
|
|
|
104
100
|
|
|
105
101
|
this._context = null;
|
|
106
102
|
this._mountOrder = 0;
|
|
107
|
-
this.
|
|
103
|
+
this._topLevelWrapper = null;
|
|
108
104
|
|
|
109
105
|
// See ReactUpdates and ReactUpdateQueue.
|
|
110
106
|
this._pendingCallbacks = null;
|
|
@@ -127,15 +123,15 @@ var ReactCompositeComponentMixin = {
|
|
|
127
123
|
var publicProps = this._processProps(this._currentElement.props);
|
|
128
124
|
var publicContext = this._processContext(context);
|
|
129
125
|
|
|
130
|
-
var Component =
|
|
126
|
+
var Component = this._currentElement.type;
|
|
131
127
|
|
|
132
128
|
// Initialize the public class
|
|
133
|
-
var inst = new Component(publicProps, publicContext);
|
|
129
|
+
var inst = new Component(publicProps, publicContext, ReactUpdateQueue);
|
|
134
130
|
|
|
135
|
-
if (
|
|
131
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
136
132
|
// This will throw later in _renderValidatedComponent, but add an early
|
|
137
133
|
// warning now to help debugging
|
|
138
|
-
|
|
134
|
+
process.env.NODE_ENV !== 'production' ? warning(inst.render != null, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render` in your ' + 'component or you may have accidentally tried to render an element ' + 'whose type is a function that isn\'t a React component.', Component.displayName || Component.name || 'Component') : undefined;
|
|
139
135
|
}
|
|
140
136
|
|
|
141
137
|
// These should be set up in the constructor, but as a convenience for
|
|
@@ -143,54 +139,48 @@ var ReactCompositeComponentMixin = {
|
|
|
143
139
|
inst.props = publicProps;
|
|
144
140
|
inst.context = publicContext;
|
|
145
141
|
inst.refs = emptyObject;
|
|
142
|
+
inst.updater = ReactUpdateQueue;
|
|
146
143
|
|
|
147
144
|
this._instance = inst;
|
|
148
145
|
|
|
149
146
|
// Store a reference from the instance back to the internal representation
|
|
150
147
|
ReactInstanceMap.set(inst, this);
|
|
151
148
|
|
|
152
|
-
if (
|
|
149
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
153
150
|
// Since plain JS classes are defined without any special initialization
|
|
154
151
|
// logic, we can not catch common errors early. Therefore, we have to
|
|
155
152
|
// catch them here, at initialization time, instead.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : undefined;
|
|
154
|
+
process.env.NODE_ENV !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : undefined;
|
|
155
|
+
process.env.NODE_ENV !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : undefined;
|
|
156
|
+
process.env.NODE_ENV !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : undefined;
|
|
157
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentShouldUpdate !== 'function', '%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.', this.getName() || 'A component') : undefined;
|
|
158
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentDidUnmount !== 'function', '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', this.getName() || 'A component') : undefined;
|
|
159
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : undefined;
|
|
161
160
|
}
|
|
162
161
|
|
|
163
162
|
var initialState = inst.state;
|
|
164
163
|
if (initialState === undefined) {
|
|
165
164
|
inst.state = initialState = null;
|
|
166
165
|
}
|
|
167
|
-
|
|
166
|
+
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
|
|
168
167
|
|
|
169
168
|
this._pendingStateQueue = null;
|
|
170
169
|
this._pendingReplaceState = false;
|
|
171
170
|
this._pendingForceUpdate = false;
|
|
172
171
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
inst.componentWillMount();
|
|
180
|
-
// When mounting, calls to `setState` by `componentWillMount` will set
|
|
181
|
-
// `this._pendingStateQueue` without triggering a re-render.
|
|
182
|
-
if (this._pendingStateQueue) {
|
|
183
|
-
inst.state = this._processPendingState(inst.props, inst.context);
|
|
184
|
-
}
|
|
172
|
+
if (inst.componentWillMount) {
|
|
173
|
+
inst.componentWillMount();
|
|
174
|
+
// When mounting, calls to `setState` by `componentWillMount` will set
|
|
175
|
+
// `this._pendingStateQueue` without triggering a re-render.
|
|
176
|
+
if (this._pendingStateQueue) {
|
|
177
|
+
inst.state = this._processPendingState(inst.props, inst.context);
|
|
185
178
|
}
|
|
186
|
-
|
|
187
|
-
renderedElement = this._renderValidatedComponent();
|
|
188
|
-
} finally {
|
|
189
|
-
ReactLifeCycle.currentlyMountingInstance = previouslyMounting;
|
|
190
179
|
}
|
|
191
180
|
|
|
192
|
-
|
|
193
|
-
|
|
181
|
+
var renderedElement = this._renderValidatedComponent();
|
|
182
|
+
|
|
183
|
+
this._renderedComponent = this._instantiateReactComponent(renderedElement);
|
|
194
184
|
|
|
195
185
|
var markup = ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, this._processChildContext(context));
|
|
196
186
|
if (inst.componentDidMount) {
|
|
@@ -210,19 +200,15 @@ var ReactCompositeComponentMixin = {
|
|
|
210
200
|
var inst = this._instance;
|
|
211
201
|
|
|
212
202
|
if (inst.componentWillUnmount) {
|
|
213
|
-
|
|
214
|
-
ReactLifeCycle.currentlyUnmountingInstance = this;
|
|
215
|
-
try {
|
|
216
|
-
inst.componentWillUnmount();
|
|
217
|
-
} finally {
|
|
218
|
-
ReactLifeCycle.currentlyUnmountingInstance = previouslyUnmounting;
|
|
219
|
-
}
|
|
203
|
+
inst.componentWillUnmount();
|
|
220
204
|
}
|
|
221
205
|
|
|
222
206
|
ReactReconciler.unmountComponent(this._renderedComponent);
|
|
223
207
|
this._renderedComponent = null;
|
|
224
208
|
|
|
225
209
|
// Reset pending fields
|
|
210
|
+
// Even if this component is scheduled for another update in ReactUpdates,
|
|
211
|
+
// it would still be ignored because these fields are reset.
|
|
226
212
|
this._pendingStateQueue = null;
|
|
227
213
|
this._pendingReplaceState = false;
|
|
228
214
|
this._pendingForceUpdate = false;
|
|
@@ -233,6 +219,7 @@ var ReactCompositeComponentMixin = {
|
|
|
233
219
|
// longer accessible.
|
|
234
220
|
this._context = null;
|
|
235
221
|
this._rootNodeID = null;
|
|
222
|
+
this._topLevelWrapper = null;
|
|
236
223
|
|
|
237
224
|
// Delete the reference from the instance to this internal representation
|
|
238
225
|
// which allow the internals to be properly cleaned up even if the user
|
|
@@ -246,22 +233,6 @@ var ReactCompositeComponentMixin = {
|
|
|
246
233
|
// TODO: inst.context = null;
|
|
247
234
|
},
|
|
248
235
|
|
|
249
|
-
/**
|
|
250
|
-
* Schedule a partial update to the props. Only used for internal testing.
|
|
251
|
-
*
|
|
252
|
-
* @param {object} partialProps Subset of the next props.
|
|
253
|
-
* @param {?function} callback Called after props are updated.
|
|
254
|
-
* @final
|
|
255
|
-
* @internal
|
|
256
|
-
*/
|
|
257
|
-
_setPropsInternal: function (partialProps, callback) {
|
|
258
|
-
// This is a deoptimized path. We optimize for always having an element.
|
|
259
|
-
// This creates an extra internal element.
|
|
260
|
-
var element = this._pendingElement || this._currentElement;
|
|
261
|
-
this._pendingElement = ReactElement.cloneAndReplaceProps(element, assign({}, element.props, partialProps));
|
|
262
|
-
ReactUpdates.enqueueUpdate(this, callback);
|
|
263
|
-
},
|
|
264
|
-
|
|
265
236
|
/**
|
|
266
237
|
* Filters the context object to only contain keys specified in
|
|
267
238
|
* `contextTypes`
|
|
@@ -272,12 +243,8 @@ var ReactCompositeComponentMixin = {
|
|
|
272
243
|
*/
|
|
273
244
|
_maskContext: function (context) {
|
|
274
245
|
var maskedContext = null;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (typeof this._currentElement.type === 'string') {
|
|
278
|
-
return emptyObject;
|
|
279
|
-
}
|
|
280
|
-
var contextTypes = this._currentElement.type.contextTypes;
|
|
246
|
+
var Component = this._currentElement.type;
|
|
247
|
+
var contextTypes = Component.contextTypes;
|
|
281
248
|
if (!contextTypes) {
|
|
282
249
|
return emptyObject;
|
|
283
250
|
}
|
|
@@ -298,8 +265,8 @@ var ReactCompositeComponentMixin = {
|
|
|
298
265
|
*/
|
|
299
266
|
_processContext: function (context) {
|
|
300
267
|
var maskedContext = this._maskContext(context);
|
|
301
|
-
if (
|
|
302
|
-
var Component =
|
|
268
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
269
|
+
var Component = this._currentElement.type;
|
|
303
270
|
if (Component.contextTypes) {
|
|
304
271
|
this._checkPropTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
|
|
305
272
|
}
|
|
@@ -313,15 +280,16 @@ var ReactCompositeComponentMixin = {
|
|
|
313
280
|
* @private
|
|
314
281
|
*/
|
|
315
282
|
_processChildContext: function (currentContext) {
|
|
283
|
+
var Component = this._currentElement.type;
|
|
316
284
|
var inst = this._instance;
|
|
317
285
|
var childContext = inst.getChildContext && inst.getChildContext();
|
|
318
286
|
if (childContext) {
|
|
319
|
-
'
|
|
320
|
-
if (
|
|
321
|
-
this._checkPropTypes(
|
|
287
|
+
!(typeof Component.childContextTypes === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
|
|
288
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
289
|
+
this._checkPropTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
|
|
322
290
|
}
|
|
323
291
|
for (var name in childContext) {
|
|
324
|
-
|
|
292
|
+
!(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(false) : undefined;
|
|
325
293
|
}
|
|
326
294
|
return assign({}, currentContext, childContext);
|
|
327
295
|
}
|
|
@@ -338,8 +306,8 @@ var ReactCompositeComponentMixin = {
|
|
|
338
306
|
* @private
|
|
339
307
|
*/
|
|
340
308
|
_processProps: function (newProps) {
|
|
341
|
-
if (
|
|
342
|
-
var Component =
|
|
309
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
310
|
+
var Component = this._currentElement.type;
|
|
343
311
|
if (Component.propTypes) {
|
|
344
312
|
this._checkPropTypes(Component.propTypes, newProps, ReactPropTypeLocations.prop);
|
|
345
313
|
}
|
|
@@ -365,7 +333,7 @@ var ReactCompositeComponentMixin = {
|
|
|
365
333
|
try {
|
|
366
334
|
// This is intentionally an invariant that gets caught. It's the same
|
|
367
335
|
// behavior as without this statement except with a better message.
|
|
368
|
-
'
|
|
336
|
+
!(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
|
|
369
337
|
error = propTypes[propName](props, propName, componentName, location);
|
|
370
338
|
} catch (ex) {
|
|
371
339
|
error = ex;
|
|
@@ -378,9 +346,9 @@ var ReactCompositeComponentMixin = {
|
|
|
378
346
|
|
|
379
347
|
if (location === ReactPropTypeLocations.prop) {
|
|
380
348
|
// Preface gives us something to blacklist in warning module
|
|
381
|
-
|
|
349
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : undefined;
|
|
382
350
|
} else {
|
|
383
|
-
|
|
351
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : undefined;
|
|
384
352
|
}
|
|
385
353
|
}
|
|
386
354
|
}
|
|
@@ -409,10 +377,6 @@ var ReactCompositeComponentMixin = {
|
|
|
409
377
|
}
|
|
410
378
|
|
|
411
379
|
if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
|
|
412
|
-
if ('production' !== process.env.NODE_ENV) {
|
|
413
|
-
ReactElementValidator.checkAndWarnForMutatedProps(this._currentElement);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
380
|
this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context);
|
|
417
381
|
}
|
|
418
382
|
},
|
|
@@ -435,14 +399,16 @@ var ReactCompositeComponentMixin = {
|
|
|
435
399
|
updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
|
|
436
400
|
var inst = this._instance;
|
|
437
401
|
|
|
438
|
-
var nextContext = inst.context;
|
|
439
|
-
var nextProps
|
|
402
|
+
var nextContext = this._context === nextUnmaskedContext ? inst.context : this._processContext(nextUnmaskedContext);
|
|
403
|
+
var nextProps;
|
|
440
404
|
|
|
441
405
|
// Distinguish between a props update versus a simple state update
|
|
442
|
-
if (prevParentElement
|
|
443
|
-
|
|
406
|
+
if (prevParentElement === nextParentElement) {
|
|
407
|
+
// Skip checking prop types again -- we don't read inst.props to avoid
|
|
408
|
+
// warning for DOM component props in this upgrade
|
|
409
|
+
nextProps = nextParentElement.props;
|
|
410
|
+
} else {
|
|
444
411
|
nextProps = this._processProps(nextParentElement.props);
|
|
445
|
-
|
|
446
412
|
// An update here will schedule an update but immediately set
|
|
447
413
|
// _pendingStateQueue which will ensure that any state updates gets
|
|
448
414
|
// immediately reconciled instead of waiting for the next batch.
|
|
@@ -456,8 +422,8 @@ var ReactCompositeComponentMixin = {
|
|
|
456
422
|
|
|
457
423
|
var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext);
|
|
458
424
|
|
|
459
|
-
if (
|
|
460
|
-
|
|
425
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
426
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof shouldUpdate !== 'undefined', '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : undefined;
|
|
461
427
|
}
|
|
462
428
|
|
|
463
429
|
if (shouldUpdate) {
|
|
@@ -514,9 +480,15 @@ var ReactCompositeComponentMixin = {
|
|
|
514
480
|
_performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) {
|
|
515
481
|
var inst = this._instance;
|
|
516
482
|
|
|
517
|
-
var
|
|
518
|
-
var
|
|
519
|
-
var
|
|
483
|
+
var hasComponentDidUpdate = Boolean(inst.componentDidUpdate);
|
|
484
|
+
var prevProps;
|
|
485
|
+
var prevState;
|
|
486
|
+
var prevContext;
|
|
487
|
+
if (hasComponentDidUpdate) {
|
|
488
|
+
prevProps = inst.props;
|
|
489
|
+
prevState = inst.state;
|
|
490
|
+
prevContext = inst.context;
|
|
491
|
+
}
|
|
520
492
|
|
|
521
493
|
if (inst.componentWillUpdate) {
|
|
522
494
|
inst.componentWillUpdate(nextProps, nextState, nextContext);
|
|
@@ -530,7 +502,7 @@ var ReactCompositeComponentMixin = {
|
|
|
530
502
|
|
|
531
503
|
this._updateRenderedComponent(transaction, unmaskedContext);
|
|
532
504
|
|
|
533
|
-
if (
|
|
505
|
+
if (hasComponentDidUpdate) {
|
|
534
506
|
transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst);
|
|
535
507
|
}
|
|
536
508
|
},
|
|
@@ -553,7 +525,7 @@ var ReactCompositeComponentMixin = {
|
|
|
553
525
|
var prevComponentID = prevComponentInstance._rootNodeID;
|
|
554
526
|
ReactReconciler.unmountComponent(prevComponentInstance);
|
|
555
527
|
|
|
556
|
-
this._renderedComponent = this._instantiateReactComponent(nextRenderedElement
|
|
528
|
+
this._renderedComponent = this._instantiateReactComponent(nextRenderedElement);
|
|
557
529
|
var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, thisID, transaction, this._processChildContext(context));
|
|
558
530
|
this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
|
|
559
531
|
}
|
|
@@ -572,7 +544,7 @@ var ReactCompositeComponentMixin = {
|
|
|
572
544
|
_renderValidatedComponentWithoutOwnerOrContext: function () {
|
|
573
545
|
var inst = this._instance;
|
|
574
546
|
var renderedComponent = inst.render();
|
|
575
|
-
if (
|
|
547
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
576
548
|
// We allow auto-mocks to proceed as if they're returning null.
|
|
577
549
|
if (typeof renderedComponent === 'undefined' && inst.render._isMockFunction) {
|
|
578
550
|
// This is probably bad practice. Consider warning here and
|
|
@@ -589,18 +561,15 @@ var ReactCompositeComponentMixin = {
|
|
|
589
561
|
*/
|
|
590
562
|
_renderValidatedComponent: function () {
|
|
591
563
|
var renderedComponent;
|
|
592
|
-
var previousContext = ReactContext.current;
|
|
593
|
-
ReactContext.current = this._processChildContext(this._currentElement._context);
|
|
594
564
|
ReactCurrentOwner.current = this;
|
|
595
565
|
try {
|
|
596
566
|
renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext();
|
|
597
567
|
} finally {
|
|
598
|
-
ReactContext.current = previousContext;
|
|
599
568
|
ReactCurrentOwner.current = null;
|
|
600
569
|
}
|
|
601
|
-
|
|
570
|
+
!(
|
|
602
571
|
// TODO: An `isValidNode` function would probably be more appropriate
|
|
603
|
-
renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent), '%s.render(): A valid ReactComponent must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(
|
|
572
|
+
renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid ReactComponent must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
|
|
604
573
|
return renderedComponent;
|
|
605
574
|
},
|
|
606
575
|
|