react 0.13.0 → 0.14.0-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +3336 -1671
- package/dist/react-with-addons.js +3134 -5113
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +2812 -4567
- 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 +9 -4
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +24 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +41 -65
- package/lib/DOMPropertyOperations.js +30 -51
- package/lib/Danger.js +19 -60
- package/lib/DefaultEventPluginOrder.js +2 -12
- package/lib/EnterLeaveEventPlugin.js +11 -33
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +11 -13
- package/lib/EventPluginHub.js +44 -47
- package/lib/EventPluginRegistry.js +18 -74
- package/lib/EventPluginUtils.js +27 -38
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +12 -18
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +34 -64
- package/lib/LocalEventTrapMixin.js +9 -16
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +8 -11
- package/lib/React.js +20 -38
- package/lib/ReactBrowserComponentMixin.js +9 -2
- package/lib/ReactBrowserEventEmitter.js +26 -82
- package/lib/ReactCSSTransitionGroup.js +13 -24
- package/lib/ReactCSSTransitionGroupChild.js +18 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +7 -16
- package/lib/ReactClass.js +78 -231
- package/lib/ReactComponent.js +17 -33
- package/lib/ReactComponentBrowserEnvironment.js +4 -6
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +4 -5
- package/lib/ReactCompositeComponent.js +85 -297
- 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/ReactDOMComponent.js +185 -146
- package/lib/ReactDOMForm.js +3 -3
- package/lib/ReactDOMIDOperations.js +11 -20
- package/lib/ReactDOMIframe.js +3 -3
- package/lib/ReactDOMImg.js +3 -3
- package/lib/ReactDOMInput.js +22 -35
- package/lib/ReactDOMOption.js +52 -10
- package/lib/ReactDOMSelect.js +53 -29
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +15 -27
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +21 -40
- package/lib/ReactDefaultPerf.js +41 -72
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +35 -72
- package/lib/ReactElementValidator.js +51 -110
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +2 -2
- package/lib/ReactEventEmitterMixin.js +3 -12
- package/lib/ReactEventListener.js +16 -38
- package/lib/ReactFragment.js +23 -54
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +11 -21
- package/lib/ReactInstanceHandles.js +27 -57
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactLifeCycle.js +1 -1
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +136 -260
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +7 -11
- package/lib/ReactOwner.js +7 -24
- package/lib/ReactPerf.js +8 -12
- package/lib/ReactPropTransferer.js +4 -4
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +13 -46
- package/lib/ReactReconcileTransaction.js +9 -34
- package/lib/ReactReconciler.js +9 -19
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +7 -15
- package/lib/ReactServerRenderingTransaction.js +7 -32
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +94 -166
- 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 -2
- package/lib/SelectEventPlugin.js +28 -29
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +136 -128
- package/lib/SyntheticClipboardEvent.js +3 -7
- package/lib/SyntheticCompositionEvent.js +3 -9
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +8 -10
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +3 -9
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +8 -14
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +3 -3
- package/lib/SyntheticWheelEvent.js +11 -15
- package/lib/Transaction.js +12 -24
- package/lib/ViewportMetrics.js +2 -2
- package/lib/accumulateInto.js +2 -5
- package/lib/adler32.js +2 -2
- package/lib/camelize.js +4 -2
- package/lib/camelizeStyleName.js +2 -2
- package/lib/cloneWithProps.js +5 -11
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createFullPageComponent.js +5 -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 -37
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +2 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +2 -2
- package/lib/keyMirror.js +3 -6
- package/lib/keyOf.js +4 -3
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +2 -2
- package/lib/onlyChild.js +2 -5
- package/lib/performance.js +2 -5
- package/lib/performanceNow.js +3 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +16 -0
- package/lib/setInnerHTML.js +11 -8
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +24 -0
- package/lib/shallowEqual.js +17 -11
- package/lib/shouldUpdateReactComponent.js +3 -64
- package/lib/toArray.js +8 -19
- package/lib/traverseAllChildren.js +19 -82
- package/lib/update.js +33 -90
- package/lib/validateDOMNesting.js +264 -0
- package/lib/warning.js +17 -15
- package/package.json +3 -3
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
package/lib/ReactComponent.js
CHANGED
|
@@ -49,22 +49,10 @@ function ReactComponent(props, context) {
|
|
|
49
49
|
* @final
|
|
50
50
|
* @protected
|
|
51
51
|
*/
|
|
52
|
-
ReactComponent.prototype.setState = function(partialState, callback) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
partialState == null,
|
|
57
|
-
'setState(...): takes an object of state variables to update or a ' +
|
|
58
|
-
'function which returns an object of state variables.'
|
|
59
|
-
) : invariant(typeof partialState === 'object' ||
|
|
60
|
-
typeof partialState === 'function' ||
|
|
61
|
-
partialState == null));
|
|
62
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
63
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
64
|
-
partialState != null,
|
|
65
|
-
'setState(...): You passed an undefined or null state object; ' +
|
|
66
|
-
'instead, use forceUpdate().'
|
|
67
|
-
) : null);
|
|
52
|
+
ReactComponent.prototype.setState = function (partialState, callback) {
|
|
53
|
+
'production' !== process.env.NODE_ENV ? invariant(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.') : invariant(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null);
|
|
54
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
55
|
+
'production' !== process.env.NODE_ENV ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : null;
|
|
68
56
|
}
|
|
69
57
|
ReactUpdateQueue.enqueueSetState(this, partialState);
|
|
70
58
|
if (callback) {
|
|
@@ -86,7 +74,7 @@ ReactComponent.prototype.setState = function(partialState, callback) {
|
|
|
86
74
|
* @final
|
|
87
75
|
* @protected
|
|
88
76
|
*/
|
|
89
|
-
ReactComponent.prototype.forceUpdate = function(callback) {
|
|
77
|
+
ReactComponent.prototype.forceUpdate = function (callback) {
|
|
90
78
|
ReactUpdateQueue.enqueueForceUpdate(this);
|
|
91
79
|
if (callback) {
|
|
92
80
|
ReactUpdateQueue.enqueueCallback(this, callback);
|
|
@@ -98,29 +86,23 @@ ReactComponent.prototype.forceUpdate = function(callback) {
|
|
|
98
86
|
* we would like to deprecate them, we're not going to move them over to this
|
|
99
87
|
* modern base class. Instead, we define a getter that warns if it's accessed.
|
|
100
88
|
*/
|
|
101
|
-
if (
|
|
89
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
102
90
|
var deprecatedAPIs = {
|
|
103
|
-
getDOMNode: 'getDOMNode',
|
|
104
|
-
isMounted: 'isMounted',
|
|
105
|
-
replaceProps: 'replaceProps',
|
|
106
|
-
replaceState: 'replaceState',
|
|
107
|
-
setProps: 'setProps'
|
|
91
|
+
getDOMNode: ['getDOMNode', 'Use React.findDOMNode(component) instead.'],
|
|
92
|
+
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
93
|
+
replaceProps: ['replaceProps', 'Instead, call React.render again at the top level.'],
|
|
94
|
+
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'],
|
|
95
|
+
setProps: ['setProps', 'Instead, call React.render again at the top level.']
|
|
108
96
|
};
|
|
109
|
-
var defineDeprecationWarning = function(methodName,
|
|
97
|
+
var defineDeprecationWarning = function (methodName, info) {
|
|
110
98
|
try {
|
|
111
99
|
Object.defineProperty(ReactComponent.prototype, methodName, {
|
|
112
|
-
get: function() {
|
|
113
|
-
|
|
114
|
-
false,
|
|
115
|
-
'%s(...) is deprecated in plain JavaScript React classes.',
|
|
116
|
-
displayName
|
|
117
|
-
) : null);
|
|
100
|
+
get: function () {
|
|
101
|
+
'production' !== process.env.NODE_ENV ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : null;
|
|
118
102
|
return undefined;
|
|
119
103
|
}
|
|
120
104
|
});
|
|
121
|
-
} catch (x) {
|
|
122
|
-
// IE will fail on defineProperty (es5-shim/sham too)
|
|
123
|
-
}
|
|
105
|
+
} catch (x) {}
|
|
124
106
|
};
|
|
125
107
|
for (var fnName in deprecatedAPIs) {
|
|
126
108
|
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
@@ -130,3 +112,5 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
130
112
|
}
|
|
131
113
|
|
|
132
114
|
module.exports = ReactComponent;
|
|
115
|
+
|
|
116
|
+
// IE will fail on defineProperty (es5-shim/sham too)
|
|
@@ -23,11 +23,9 @@ var ReactMount = require("./ReactMount");
|
|
|
23
23
|
*/
|
|
24
24
|
var ReactComponentBrowserEnvironment = {
|
|
25
25
|
|
|
26
|
-
processChildrenUpdates:
|
|
27
|
-
ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
|
|
26
|
+
processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
|
|
28
27
|
|
|
29
|
-
replaceNodeWithMarkupByID:
|
|
30
|
-
ReactDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
|
|
28
|
+
replaceNodeWithMarkupByID: ReactDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
|
|
31
29
|
|
|
32
30
|
/**
|
|
33
31
|
* If a particular environment requires that some resources be cleaned up,
|
|
@@ -36,10 +34,10 @@ var ReactComponentBrowserEnvironment = {
|
|
|
36
34
|
*
|
|
37
35
|
* @private
|
|
38
36
|
*/
|
|
39
|
-
unmountIDFromEnvironment: function(rootNodeID) {
|
|
37
|
+
unmountIDFromEnvironment: function (rootNodeID) {
|
|
40
38
|
ReactMount.purgeID(rootNodeID);
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
};
|
|
44
42
|
|
|
45
|
-
module.exports = ReactComponentBrowserEnvironment;
|
|
43
|
+
module.exports = ReactComponentBrowserEnvironment;
|
|
@@ -37,21 +37,15 @@ var ReactComponentEnvironment = {
|
|
|
37
37
|
processChildrenUpdates: null,
|
|
38
38
|
|
|
39
39
|
injection: {
|
|
40
|
-
injectEnvironment: function(environment) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
ReactComponentEnvironment.unmountIDFromEnvironment =
|
|
46
|
-
environment.unmountIDFromEnvironment;
|
|
47
|
-
ReactComponentEnvironment.replaceNodeWithMarkupByID =
|
|
48
|
-
environment.replaceNodeWithMarkupByID;
|
|
49
|
-
ReactComponentEnvironment.processChildrenUpdates =
|
|
50
|
-
environment.processChildrenUpdates;
|
|
40
|
+
injectEnvironment: function (environment) {
|
|
41
|
+
'production' !== process.env.NODE_ENV ? invariant(!injected, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(!injected);
|
|
42
|
+
ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
|
|
43
|
+
ReactComponentEnvironment.replaceNodeWithMarkupByID = environment.replaceNodeWithMarkupByID;
|
|
44
|
+
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
|
|
51
45
|
injected = true;
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
48
|
|
|
55
49
|
};
|
|
56
50
|
|
|
57
|
-
module.exports = ReactComponentEnvironment;
|
|
51
|
+
module.exports = ReactComponentEnvironment;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
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
|
|
@@ -38,10 +38,9 @@ var shallowEqual = require("./shallowEqual");
|
|
|
38
38
|
* use `forceUpdate()` when you know deep data structures have changed.
|
|
39
39
|
*/
|
|
40
40
|
var ReactComponentWithPureRenderMixin = {
|
|
41
|
-
shouldComponentUpdate: function(nextProps, nextState) {
|
|
42
|
-
return
|
|
43
|
-
!shallowEqual(this.state, nextState);
|
|
41
|
+
shouldComponentUpdate: function (nextProps, nextState) {
|
|
42
|
+
return shallowCompare(this, nextProps, nextState);
|
|
44
43
|
}
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
module.exports = ReactComponentWithPureRenderMixin;
|
|
46
|
+
module.exports = ReactComponentWithPureRenderMixin;
|
|
@@ -89,7 +89,7 @@ var ReactCompositeComponentMixin = {
|
|
|
89
89
|
* @final
|
|
90
90
|
* @internal
|
|
91
91
|
*/
|
|
92
|
-
construct: function(element) {
|
|
92
|
+
construct: function (element) {
|
|
93
93
|
this._currentElement = element;
|
|
94
94
|
this._rootNodeID = null;
|
|
95
95
|
this._instance = null;
|
|
@@ -119,32 +119,23 @@ var ReactCompositeComponentMixin = {
|
|
|
119
119
|
* @final
|
|
120
120
|
* @internal
|
|
121
121
|
*/
|
|
122
|
-
mountComponent: function(rootID, transaction, context) {
|
|
122
|
+
mountComponent: function (rootID, transaction, context) {
|
|
123
123
|
this._context = context;
|
|
124
124
|
this._mountOrder = nextMountID++;
|
|
125
125
|
this._rootNodeID = rootID;
|
|
126
126
|
|
|
127
127
|
var publicProps = this._processProps(this._currentElement.props);
|
|
128
|
-
var publicContext = this._processContext(
|
|
128
|
+
var publicContext = this._processContext(context);
|
|
129
129
|
|
|
130
|
-
var Component = ReactNativeComponent.getComponentClassForElement(
|
|
131
|
-
this._currentElement
|
|
132
|
-
);
|
|
130
|
+
var Component = ReactNativeComponent.getComponentClassForElement(this._currentElement);
|
|
133
131
|
|
|
134
132
|
// Initialize the public class
|
|
135
133
|
var inst = new Component(publicProps, publicContext);
|
|
136
134
|
|
|
137
|
-
if (
|
|
135
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
138
136
|
// This will throw later in _renderValidatedComponent, but add an early
|
|
139
137
|
// warning now to help debugging
|
|
140
|
-
|
|
141
|
-
inst.render != null,
|
|
142
|
-
'%s(...): No `render` method found on the returned component ' +
|
|
143
|
-
'instance: you may have forgotten to define `render` in your ' +
|
|
144
|
-
'component or you may have accidentally tried to render an element ' +
|
|
145
|
-
'whose type is a function that isn\'t a React component.',
|
|
146
|
-
Component.displayName || Component.name || 'Component'
|
|
147
|
-
) : null);
|
|
138
|
+
'production' !== process.env.NODE_ENV ? 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') : null;
|
|
148
139
|
}
|
|
149
140
|
|
|
150
141
|
// These should be set up in the constructor, but as a convenience for
|
|
@@ -158,53 +149,22 @@ var ReactCompositeComponentMixin = {
|
|
|
158
149
|
// Store a reference from the instance back to the internal representation
|
|
159
150
|
ReactInstanceMap.set(inst, this);
|
|
160
151
|
|
|
161
|
-
if (
|
|
162
|
-
this._warnIfContextsDiffer(this._currentElement._context, context);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
152
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
166
153
|
// Since plain JS classes are defined without any special initialization
|
|
167
154
|
// logic, we can not catch common errors early. Therefore, we have to
|
|
168
155
|
// catch them here, at initialization time, instead.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
'Did you mean to define a state property instead?',
|
|
175
|
-
this.getName() || 'a component'
|
|
176
|
-
) : null);
|
|
177
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
178
|
-
!inst.propTypes,
|
|
179
|
-
'propTypes was defined as an instance property on %s. Use a static ' +
|
|
180
|
-
'property to define propTypes instead.',
|
|
181
|
-
this.getName() || 'a component'
|
|
182
|
-
) : null);
|
|
183
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
184
|
-
!inst.contextTypes,
|
|
185
|
-
'contextTypes was defined as an instance property on %s. Use a ' +
|
|
186
|
-
'static property to define contextTypes instead.',
|
|
187
|
-
this.getName() || 'a component'
|
|
188
|
-
) : null);
|
|
189
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
190
|
-
typeof inst.componentShouldUpdate !== 'function',
|
|
191
|
-
'%s has a method called ' +
|
|
192
|
-
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
|
|
193
|
-
'The name is phrased as a question because the function is ' +
|
|
194
|
-
'expected to return a value.',
|
|
195
|
-
(this.getName() || 'A component')
|
|
196
|
-
) : null);
|
|
156
|
+
'production' !== process.env.NODE_ENV ? 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') : null;
|
|
157
|
+
'production' !== process.env.NODE_ENV ? 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') : null;
|
|
158
|
+
'production' !== process.env.NODE_ENV ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : null;
|
|
159
|
+
'production' !== process.env.NODE_ENV ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : null;
|
|
160
|
+
'production' !== process.env.NODE_ENV ? 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') : null;
|
|
197
161
|
}
|
|
198
162
|
|
|
199
163
|
var initialState = inst.state;
|
|
200
164
|
if (initialState === undefined) {
|
|
201
165
|
inst.state = initialState = null;
|
|
202
166
|
}
|
|
203
|
-
|
|
204
|
-
typeof initialState === 'object' && !Array.isArray(initialState),
|
|
205
|
-
'%s.state: must be set to an object or null',
|
|
206
|
-
this.getName() || 'ReactCompositeComponent'
|
|
207
|
-
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
|
|
167
|
+
'production' !== process.env.NODE_ENV ? invariant(typeof initialState === 'object' && !Array.isArray(initialState), '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(typeof initialState === 'object' && !Array.isArray(initialState));
|
|
208
168
|
|
|
209
169
|
this._pendingStateQueue = null;
|
|
210
170
|
this._pendingReplaceState = false;
|
|
@@ -229,17 +189,10 @@ var ReactCompositeComponentMixin = {
|
|
|
229
189
|
ReactLifeCycle.currentlyMountingInstance = previouslyMounting;
|
|
230
190
|
}
|
|
231
191
|
|
|
232
|
-
this._renderedComponent = this._instantiateReactComponent(
|
|
233
|
-
renderedElement,
|
|
234
|
-
this._currentElement.type // The wrapping type
|
|
192
|
+
this._renderedComponent = this._instantiateReactComponent(renderedElement, this._currentElement.type // The wrapping type
|
|
235
193
|
);
|
|
236
194
|
|
|
237
|
-
var markup = ReactReconciler.mountComponent(
|
|
238
|
-
this._renderedComponent,
|
|
239
|
-
rootID,
|
|
240
|
-
transaction,
|
|
241
|
-
this._processChildContext(context)
|
|
242
|
-
);
|
|
195
|
+
var markup = ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, this._processChildContext(context));
|
|
243
196
|
if (inst.componentDidMount) {
|
|
244
197
|
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
|
|
245
198
|
}
|
|
@@ -253,7 +206,7 @@ var ReactCompositeComponentMixin = {
|
|
|
253
206
|
* @final
|
|
254
207
|
* @internal
|
|
255
208
|
*/
|
|
256
|
-
unmountComponent: function() {
|
|
209
|
+
unmountComponent: function () {
|
|
257
210
|
var inst = this._instance;
|
|
258
211
|
|
|
259
212
|
if (inst.componentWillUnmount) {
|
|
@@ -301,14 +254,11 @@ var ReactCompositeComponentMixin = {
|
|
|
301
254
|
* @final
|
|
302
255
|
* @internal
|
|
303
256
|
*/
|
|
304
|
-
_setPropsInternal: function(partialProps, callback) {
|
|
257
|
+
_setPropsInternal: function (partialProps, callback) {
|
|
305
258
|
// This is a deoptimized path. We optimize for always having an element.
|
|
306
259
|
// This creates an extra internal element.
|
|
307
260
|
var element = this._pendingElement || this._currentElement;
|
|
308
|
-
this._pendingElement = ReactElement.cloneAndReplaceProps(
|
|
309
|
-
element,
|
|
310
|
-
assign({}, element.props, partialProps)
|
|
311
|
-
);
|
|
261
|
+
this._pendingElement = ReactElement.cloneAndReplaceProps(element, assign({}, element.props, partialProps));
|
|
312
262
|
ReactUpdates.enqueueUpdate(this, callback);
|
|
313
263
|
},
|
|
314
264
|
|
|
@@ -320,7 +270,7 @@ var ReactCompositeComponentMixin = {
|
|
|
320
270
|
* @return {?object}
|
|
321
271
|
* @private
|
|
322
272
|
*/
|
|
323
|
-
_maskContext: function(context) {
|
|
273
|
+
_maskContext: function (context) {
|
|
324
274
|
var maskedContext = null;
|
|
325
275
|
// This really should be getting the component class for the element,
|
|
326
276
|
// but we know that we're not going to need it for built-ins.
|
|
@@ -346,18 +296,12 @@ var ReactCompositeComponentMixin = {
|
|
|
346
296
|
* @return {?object}
|
|
347
297
|
* @private
|
|
348
298
|
*/
|
|
349
|
-
_processContext: function(context) {
|
|
299
|
+
_processContext: function (context) {
|
|
350
300
|
var maskedContext = this._maskContext(context);
|
|
351
|
-
if (
|
|
352
|
-
var Component = ReactNativeComponent.getComponentClassForElement(
|
|
353
|
-
this._currentElement
|
|
354
|
-
);
|
|
301
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
302
|
+
var Component = ReactNativeComponent.getComponentClassForElement(this._currentElement);
|
|
355
303
|
if (Component.contextTypes) {
|
|
356
|
-
this._checkPropTypes(
|
|
357
|
-
Component.contextTypes,
|
|
358
|
-
maskedContext,
|
|
359
|
-
ReactPropTypeLocations.context
|
|
360
|
-
);
|
|
304
|
+
this._checkPropTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
|
|
361
305
|
}
|
|
362
306
|
}
|
|
363
307
|
return maskedContext;
|
|
@@ -368,30 +312,16 @@ var ReactCompositeComponentMixin = {
|
|
|
368
312
|
* @return {object}
|
|
369
313
|
* @private
|
|
370
314
|
*/
|
|
371
|
-
_processChildContext: function(currentContext) {
|
|
315
|
+
_processChildContext: function (currentContext) {
|
|
372
316
|
var inst = this._instance;
|
|
373
317
|
var childContext = inst.getChildContext && inst.getChildContext();
|
|
374
318
|
if (childContext) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
'use getChildContext().',
|
|
379
|
-
this.getName() || 'ReactCompositeComponent'
|
|
380
|
-
) : invariant(typeof inst.constructor.childContextTypes === 'object'));
|
|
381
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
382
|
-
this._checkPropTypes(
|
|
383
|
-
inst.constructor.childContextTypes,
|
|
384
|
-
childContext,
|
|
385
|
-
ReactPropTypeLocations.childContext
|
|
386
|
-
);
|
|
319
|
+
'production' !== process.env.NODE_ENV ? invariant(typeof inst.constructor.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(typeof inst.constructor.childContextTypes === 'object');
|
|
320
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
321
|
+
this._checkPropTypes(inst.constructor.childContextTypes, childContext, ReactPropTypeLocations.childContext);
|
|
387
322
|
}
|
|
388
323
|
for (var name in childContext) {
|
|
389
|
-
|
|
390
|
-
name in inst.constructor.childContextTypes,
|
|
391
|
-
'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
|
|
392
|
-
this.getName() || 'ReactCompositeComponent',
|
|
393
|
-
name
|
|
394
|
-
) : invariant(name in inst.constructor.childContextTypes));
|
|
324
|
+
'production' !== process.env.NODE_ENV ? invariant(name in inst.constructor.childContextTypes, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(name in inst.constructor.childContextTypes);
|
|
395
325
|
}
|
|
396
326
|
return assign({}, currentContext, childContext);
|
|
397
327
|
}
|
|
@@ -407,17 +337,11 @@ var ReactCompositeComponentMixin = {
|
|
|
407
337
|
* @return {object}
|
|
408
338
|
* @private
|
|
409
339
|
*/
|
|
410
|
-
_processProps: function(newProps) {
|
|
411
|
-
if (
|
|
412
|
-
var Component = ReactNativeComponent.getComponentClassForElement(
|
|
413
|
-
this._currentElement
|
|
414
|
-
);
|
|
340
|
+
_processProps: function (newProps) {
|
|
341
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
342
|
+
var Component = ReactNativeComponent.getComponentClassForElement(this._currentElement);
|
|
415
343
|
if (Component.propTypes) {
|
|
416
|
-
this._checkPropTypes(
|
|
417
|
-
Component.propTypes,
|
|
418
|
-
newProps,
|
|
419
|
-
ReactPropTypeLocations.prop
|
|
420
|
-
);
|
|
344
|
+
this._checkPropTypes(Component.propTypes, newProps, ReactPropTypeLocations.prop);
|
|
421
345
|
}
|
|
422
346
|
}
|
|
423
347
|
return newProps;
|
|
@@ -431,7 +355,7 @@ var ReactCompositeComponentMixin = {
|
|
|
431
355
|
* @param {string} location e.g. "prop", "context", "child context"
|
|
432
356
|
* @private
|
|
433
357
|
*/
|
|
434
|
-
_checkPropTypes: function(propTypes, props, location) {
|
|
358
|
+
_checkPropTypes: function (propTypes, props, location) {
|
|
435
359
|
// TODO: Stop validating prop types here and only use the element
|
|
436
360
|
// validation.
|
|
437
361
|
var componentName = this.getName();
|
|
@@ -441,14 +365,7 @@ var ReactCompositeComponentMixin = {
|
|
|
441
365
|
try {
|
|
442
366
|
// This is intentionally an invariant that gets caught. It's the same
|
|
443
367
|
// behavior as without this statement except with a better message.
|
|
444
|
-
|
|
445
|
-
typeof propTypes[propName] === 'function',
|
|
446
|
-
'%s: %s type `%s` is invalid; it must be a function, usually ' +
|
|
447
|
-
'from React.PropTypes.',
|
|
448
|
-
componentName || 'React class',
|
|
449
|
-
ReactPropTypeLocationNames[location],
|
|
450
|
-
propName
|
|
451
|
-
) : invariant(typeof propTypes[propName] === 'function'));
|
|
368
|
+
'production' !== process.env.NODE_ENV ? invariant(typeof propTypes[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(typeof propTypes[propName] === 'function');
|
|
452
369
|
error = propTypes[propName](props, propName, componentName, location);
|
|
453
370
|
} catch (ex) {
|
|
454
371
|
error = ex;
|
|
@@ -461,38 +378,22 @@ var ReactCompositeComponentMixin = {
|
|
|
461
378
|
|
|
462
379
|
if (location === ReactPropTypeLocations.prop) {
|
|
463
380
|
// Preface gives us something to blacklist in warning module
|
|
464
|
-
|
|
465
|
-
false,
|
|
466
|
-
'Failed Composite propType: %s%s',
|
|
467
|
-
error.message,
|
|
468
|
-
addendum
|
|
469
|
-
) : null);
|
|
381
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : null;
|
|
470
382
|
} else {
|
|
471
|
-
|
|
472
|
-
false,
|
|
473
|
-
'Failed Context Types: %s%s',
|
|
474
|
-
error.message,
|
|
475
|
-
addendum
|
|
476
|
-
) : null);
|
|
383
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : null;
|
|
477
384
|
}
|
|
478
385
|
}
|
|
479
386
|
}
|
|
480
387
|
}
|
|
481
388
|
},
|
|
482
389
|
|
|
483
|
-
receiveComponent: function(nextElement, transaction, nextContext) {
|
|
390
|
+
receiveComponent: function (nextElement, transaction, nextContext) {
|
|
484
391
|
var prevElement = this._currentElement;
|
|
485
392
|
var prevContext = this._context;
|
|
486
393
|
|
|
487
394
|
this._pendingElement = null;
|
|
488
395
|
|
|
489
|
-
this.updateComponent(
|
|
490
|
-
transaction,
|
|
491
|
-
prevElement,
|
|
492
|
-
nextElement,
|
|
493
|
-
prevContext,
|
|
494
|
-
nextContext
|
|
495
|
-
);
|
|
396
|
+
this.updateComponent(transaction, prevElement, nextElement, prevContext, nextContext);
|
|
496
397
|
},
|
|
497
398
|
|
|
498
399
|
/**
|
|
@@ -502,54 +403,17 @@ var ReactCompositeComponentMixin = {
|
|
|
502
403
|
* @param {ReactReconcileTransaction} transaction
|
|
503
404
|
* @internal
|
|
504
405
|
*/
|
|
505
|
-
performUpdateIfNecessary: function(transaction) {
|
|
406
|
+
performUpdateIfNecessary: function (transaction) {
|
|
506
407
|
if (this._pendingElement != null) {
|
|
507
|
-
ReactReconciler.receiveComponent(
|
|
508
|
-
this,
|
|
509
|
-
this._pendingElement || this._currentElement,
|
|
510
|
-
transaction,
|
|
511
|
-
this._context
|
|
512
|
-
);
|
|
408
|
+
ReactReconciler.receiveComponent(this, this._pendingElement || this._currentElement, transaction, this._context);
|
|
513
409
|
}
|
|
514
410
|
|
|
515
411
|
if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
|
|
516
|
-
if (
|
|
517
|
-
ReactElementValidator.checkAndWarnForMutatedProps(
|
|
518
|
-
this._currentElement
|
|
519
|
-
);
|
|
412
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
413
|
+
ReactElementValidator.checkAndWarnForMutatedProps(this._currentElement);
|
|
520
414
|
}
|
|
521
415
|
|
|
522
|
-
this.updateComponent(
|
|
523
|
-
transaction,
|
|
524
|
-
this._currentElement,
|
|
525
|
-
this._currentElement,
|
|
526
|
-
this._context,
|
|
527
|
-
this._context
|
|
528
|
-
);
|
|
529
|
-
}
|
|
530
|
-
},
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* Compare two contexts, warning if they are different
|
|
534
|
-
* TODO: Remove this check when owner-context is removed
|
|
535
|
-
*/
|
|
536
|
-
_warnIfContextsDiffer: function(ownerBasedContext, parentBasedContext) {
|
|
537
|
-
ownerBasedContext = this._maskContext(ownerBasedContext);
|
|
538
|
-
parentBasedContext = this._maskContext(parentBasedContext);
|
|
539
|
-
var parentKeys = Object.keys(parentBasedContext).sort();
|
|
540
|
-
var displayName = this.getName() || 'ReactCompositeComponent';
|
|
541
|
-
for (var i = 0; i < parentKeys.length; i++) {
|
|
542
|
-
var key = parentKeys[i];
|
|
543
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
544
|
-
ownerBasedContext[key] === parentBasedContext[key],
|
|
545
|
-
'owner-based and parent-based contexts differ ' +
|
|
546
|
-
'(values: `%s` vs `%s`) for key (%s) while mounting %s ' +
|
|
547
|
-
'(see: http://fb.me/react-context-by-parent)',
|
|
548
|
-
ownerBasedContext[key],
|
|
549
|
-
parentBasedContext[key],
|
|
550
|
-
key,
|
|
551
|
-
displayName
|
|
552
|
-
) : null);
|
|
416
|
+
this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context);
|
|
553
417
|
}
|
|
554
418
|
},
|
|
555
419
|
|
|
@@ -568,13 +432,7 @@ var ReactCompositeComponentMixin = {
|
|
|
568
432
|
* @internal
|
|
569
433
|
* @overridable
|
|
570
434
|
*/
|
|
571
|
-
updateComponent: function(
|
|
572
|
-
transaction,
|
|
573
|
-
prevParentElement,
|
|
574
|
-
nextParentElement,
|
|
575
|
-
prevUnmaskedContext,
|
|
576
|
-
nextUnmaskedContext
|
|
577
|
-
) {
|
|
435
|
+
updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
|
|
578
436
|
var inst = this._instance;
|
|
579
437
|
|
|
580
438
|
var nextContext = inst.context;
|
|
@@ -582,18 +440,9 @@ var ReactCompositeComponentMixin = {
|
|
|
582
440
|
|
|
583
441
|
// Distinguish between a props update versus a simple state update
|
|
584
442
|
if (prevParentElement !== nextParentElement) {
|
|
585
|
-
nextContext = this._processContext(
|
|
443
|
+
nextContext = this._processContext(nextUnmaskedContext);
|
|
586
444
|
nextProps = this._processProps(nextParentElement.props);
|
|
587
445
|
|
|
588
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
589
|
-
if (nextUnmaskedContext != null) {
|
|
590
|
-
this._warnIfContextsDiffer(
|
|
591
|
-
nextParentElement._context,
|
|
592
|
-
nextUnmaskedContext
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
446
|
// An update here will schedule an update but immediately set
|
|
598
447
|
// _pendingStateQueue which will ensure that any state updates gets
|
|
599
448
|
// immediately reconciled instead of waiting for the next batch.
|
|
@@ -605,31 +454,16 @@ var ReactCompositeComponentMixin = {
|
|
|
605
454
|
|
|
606
455
|
var nextState = this._processPendingState(nextProps, nextContext);
|
|
607
456
|
|
|
608
|
-
var shouldUpdate =
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
614
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
615
|
-
typeof shouldUpdate !== 'undefined',
|
|
616
|
-
'%s.shouldComponentUpdate(): Returned undefined instead of a ' +
|
|
617
|
-
'boolean value. Make sure to return true or false.',
|
|
618
|
-
this.getName() || 'ReactCompositeComponent'
|
|
619
|
-
) : null);
|
|
457
|
+
var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext);
|
|
458
|
+
|
|
459
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
460
|
+
'production' !== process.env.NODE_ENV ? warning(typeof shouldUpdate !== 'undefined', '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : null;
|
|
620
461
|
}
|
|
621
462
|
|
|
622
463
|
if (shouldUpdate) {
|
|
623
464
|
this._pendingForceUpdate = false;
|
|
624
465
|
// Will set `this.props`, `this.state` and `this.context`.
|
|
625
|
-
this._performComponentUpdate(
|
|
626
|
-
nextParentElement,
|
|
627
|
-
nextProps,
|
|
628
|
-
nextState,
|
|
629
|
-
nextContext,
|
|
630
|
-
transaction,
|
|
631
|
-
nextUnmaskedContext
|
|
632
|
-
);
|
|
466
|
+
this._performComponentUpdate(nextParentElement, nextProps, nextState, nextContext, transaction, nextUnmaskedContext);
|
|
633
467
|
} else {
|
|
634
468
|
// If it's determined that a component should not update, we still want
|
|
635
469
|
// to set props and state but we shortcut the rest of the update.
|
|
@@ -641,7 +475,7 @@ var ReactCompositeComponentMixin = {
|
|
|
641
475
|
}
|
|
642
476
|
},
|
|
643
477
|
|
|
644
|
-
_processPendingState: function(props, context) {
|
|
478
|
+
_processPendingState: function (props, context) {
|
|
645
479
|
var inst = this._instance;
|
|
646
480
|
var queue = this._pendingStateQueue;
|
|
647
481
|
var replace = this._pendingReplaceState;
|
|
@@ -652,15 +486,14 @@ var ReactCompositeComponentMixin = {
|
|
|
652
486
|
return inst.state;
|
|
653
487
|
}
|
|
654
488
|
|
|
489
|
+
if (replace && queue.length === 1) {
|
|
490
|
+
return queue[0];
|
|
491
|
+
}
|
|
492
|
+
|
|
655
493
|
var nextState = assign({}, replace ? queue[0] : inst.state);
|
|
656
494
|
for (var i = replace ? 1 : 0; i < queue.length; i++) {
|
|
657
495
|
var partial = queue[i];
|
|
658
|
-
assign(
|
|
659
|
-
nextState,
|
|
660
|
-
typeof partial === 'function' ?
|
|
661
|
-
partial.call(inst, nextState, props, context) :
|
|
662
|
-
partial
|
|
663
|
-
);
|
|
496
|
+
assign(nextState, typeof partial === 'function' ? partial.call(inst, nextState, props, context) : partial);
|
|
664
497
|
}
|
|
665
498
|
|
|
666
499
|
return nextState;
|
|
@@ -678,14 +511,7 @@ var ReactCompositeComponentMixin = {
|
|
|
678
511
|
* @param {?object} unmaskedContext
|
|
679
512
|
* @private
|
|
680
513
|
*/
|
|
681
|
-
_performComponentUpdate: function(
|
|
682
|
-
nextElement,
|
|
683
|
-
nextProps,
|
|
684
|
-
nextState,
|
|
685
|
-
nextContext,
|
|
686
|
-
transaction,
|
|
687
|
-
unmaskedContext
|
|
688
|
-
) {
|
|
514
|
+
_performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) {
|
|
689
515
|
var inst = this._instance;
|
|
690
516
|
|
|
691
517
|
var prevProps = inst.props;
|
|
@@ -705,10 +531,7 @@ var ReactCompositeComponentMixin = {
|
|
|
705
531
|
this._updateRenderedComponent(transaction, unmaskedContext);
|
|
706
532
|
|
|
707
533
|
if (inst.componentDidUpdate) {
|
|
708
|
-
transaction.getReactMountReady().enqueue(
|
|
709
|
-
inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext),
|
|
710
|
-
inst
|
|
711
|
-
);
|
|
534
|
+
transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst);
|
|
712
535
|
}
|
|
713
536
|
},
|
|
714
537
|
|
|
@@ -718,33 +541,20 @@ var ReactCompositeComponentMixin = {
|
|
|
718
541
|
* @param {ReactReconcileTransaction} transaction
|
|
719
542
|
* @internal
|
|
720
543
|
*/
|
|
721
|
-
_updateRenderedComponent: function(transaction, context) {
|
|
544
|
+
_updateRenderedComponent: function (transaction, context) {
|
|
722
545
|
var prevComponentInstance = this._renderedComponent;
|
|
723
546
|
var prevRenderedElement = prevComponentInstance._currentElement;
|
|
724
547
|
var nextRenderedElement = this._renderValidatedComponent();
|
|
725
548
|
if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
|
|
726
|
-
ReactReconciler.receiveComponent(
|
|
727
|
-
prevComponentInstance,
|
|
728
|
-
nextRenderedElement,
|
|
729
|
-
transaction,
|
|
730
|
-
this._processChildContext(context)
|
|
731
|
-
);
|
|
549
|
+
ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
|
|
732
550
|
} else {
|
|
733
551
|
// These two IDs are actually the same! But nothing should rely on that.
|
|
734
552
|
var thisID = this._rootNodeID;
|
|
735
553
|
var prevComponentID = prevComponentInstance._rootNodeID;
|
|
736
554
|
ReactReconciler.unmountComponent(prevComponentInstance);
|
|
737
555
|
|
|
738
|
-
this._renderedComponent = this._instantiateReactComponent(
|
|
739
|
-
|
|
740
|
-
this._currentElement.type
|
|
741
|
-
);
|
|
742
|
-
var nextMarkup = ReactReconciler.mountComponent(
|
|
743
|
-
this._renderedComponent,
|
|
744
|
-
thisID,
|
|
745
|
-
transaction,
|
|
746
|
-
context
|
|
747
|
-
);
|
|
556
|
+
this._renderedComponent = this._instantiateReactComponent(nextRenderedElement, this._currentElement.type);
|
|
557
|
+
var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, thisID, transaction, this._processChildContext(context));
|
|
748
558
|
this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
|
|
749
559
|
}
|
|
750
560
|
},
|
|
@@ -752,23 +562,19 @@ var ReactCompositeComponentMixin = {
|
|
|
752
562
|
/**
|
|
753
563
|
* @protected
|
|
754
564
|
*/
|
|
755
|
-
_replaceNodeWithMarkupByID: function(prevComponentID, nextMarkup) {
|
|
756
|
-
ReactComponentEnvironment.replaceNodeWithMarkupByID(
|
|
757
|
-
prevComponentID,
|
|
758
|
-
nextMarkup
|
|
759
|
-
);
|
|
565
|
+
_replaceNodeWithMarkupByID: function (prevComponentID, nextMarkup) {
|
|
566
|
+
ReactComponentEnvironment.replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
|
|
760
567
|
},
|
|
761
568
|
|
|
762
569
|
/**
|
|
763
570
|
* @protected
|
|
764
571
|
*/
|
|
765
|
-
_renderValidatedComponentWithoutOwnerOrContext: function() {
|
|
572
|
+
_renderValidatedComponentWithoutOwnerOrContext: function () {
|
|
766
573
|
var inst = this._instance;
|
|
767
574
|
var renderedComponent = inst.render();
|
|
768
|
-
if (
|
|
575
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
769
576
|
// We allow auto-mocks to proceed as if they're returning null.
|
|
770
|
-
if (typeof renderedComponent === 'undefined' &&
|
|
771
|
-
inst.render._isMockFunction) {
|
|
577
|
+
if (typeof renderedComponent === 'undefined' && inst.render._isMockFunction) {
|
|
772
578
|
// This is probably bad practice. Consider warning here and
|
|
773
579
|
// deprecating this convenience.
|
|
774
580
|
renderedComponent = null;
|
|
@@ -781,30 +587,20 @@ var ReactCompositeComponentMixin = {
|
|
|
781
587
|
/**
|
|
782
588
|
* @private
|
|
783
589
|
*/
|
|
784
|
-
_renderValidatedComponent: function() {
|
|
590
|
+
_renderValidatedComponent: function () {
|
|
785
591
|
var renderedComponent;
|
|
786
592
|
var previousContext = ReactContext.current;
|
|
787
|
-
ReactContext.current = this._processChildContext(
|
|
788
|
-
this._currentElement._context
|
|
789
|
-
);
|
|
593
|
+
ReactContext.current = this._processChildContext(this._currentElement._context);
|
|
790
594
|
ReactCurrentOwner.current = this;
|
|
791
595
|
try {
|
|
792
|
-
renderedComponent =
|
|
793
|
-
this._renderValidatedComponentWithoutOwnerOrContext();
|
|
596
|
+
renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext();
|
|
794
597
|
} finally {
|
|
795
598
|
ReactContext.current = previousContext;
|
|
796
599
|
ReactCurrentOwner.current = null;
|
|
797
600
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
ReactElement.isValidElement(renderedComponent),
|
|
802
|
-
'%s.render(): A valid ReactComponent must be returned. You may have ' +
|
|
803
|
-
'returned undefined, an array or some other invalid object.',
|
|
804
|
-
this.getName() || 'ReactCompositeComponent'
|
|
805
|
-
) : invariant(// TODO: An `isValidNode` function would probably be more appropriate
|
|
806
|
-
renderedComponent === null || renderedComponent === false ||
|
|
807
|
-
ReactElement.isValidElement(renderedComponent)));
|
|
601
|
+
'production' !== process.env.NODE_ENV ? invariant(
|
|
602
|
+
// 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(renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent));
|
|
808
604
|
return renderedComponent;
|
|
809
605
|
},
|
|
810
606
|
|
|
@@ -816,9 +612,9 @@ var ReactCompositeComponentMixin = {
|
|
|
816
612
|
* @final
|
|
817
613
|
* @private
|
|
818
614
|
*/
|
|
819
|
-
attachRef: function(ref, component) {
|
|
615
|
+
attachRef: function (ref, component) {
|
|
820
616
|
var inst = this.getPublicInstance();
|
|
821
|
-
var refs = inst.refs === emptyObject ?
|
|
617
|
+
var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs;
|
|
822
618
|
refs[ref] = component.getPublicInstance();
|
|
823
619
|
},
|
|
824
620
|
|
|
@@ -829,7 +625,7 @@ var ReactCompositeComponentMixin = {
|
|
|
829
625
|
* @final
|
|
830
626
|
* @private
|
|
831
627
|
*/
|
|
832
|
-
detachRef: function(ref) {
|
|
628
|
+
detachRef: function (ref) {
|
|
833
629
|
var refs = this.getPublicInstance().refs;
|
|
834
630
|
delete refs[ref];
|
|
835
631
|
},
|
|
@@ -840,14 +636,10 @@ var ReactCompositeComponentMixin = {
|
|
|
840
636
|
* @return {string} The name or null.
|
|
841
637
|
* @internal
|
|
842
638
|
*/
|
|
843
|
-
getName: function() {
|
|
639
|
+
getName: function () {
|
|
844
640
|
var type = this._currentElement.type;
|
|
845
641
|
var constructor = this._instance && this._instance.constructor;
|
|
846
|
-
return
|
|
847
|
-
type.displayName || (constructor && constructor.displayName) ||
|
|
848
|
-
type.name || (constructor && constructor.name) ||
|
|
849
|
-
null
|
|
850
|
-
);
|
|
642
|
+
return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null;
|
|
851
643
|
},
|
|
852
644
|
|
|
853
645
|
/**
|
|
@@ -858,7 +650,7 @@ var ReactCompositeComponentMixin = {
|
|
|
858
650
|
* @return {ReactComponent} the public component instance.
|
|
859
651
|
* @internal
|
|
860
652
|
*/
|
|
861
|
-
getPublicInstance: function() {
|
|
653
|
+
getPublicInstance: function () {
|
|
862
654
|
return this._instance;
|
|
863
655
|
},
|
|
864
656
|
|
|
@@ -867,15 +659,11 @@ var ReactCompositeComponentMixin = {
|
|
|
867
659
|
|
|
868
660
|
};
|
|
869
661
|
|
|
870
|
-
ReactPerf.measureMethods(
|
|
871
|
-
|
|
872
|
-
'
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
updateComponent: 'updateComponent',
|
|
876
|
-
_renderValidatedComponent: '_renderValidatedComponent'
|
|
877
|
-
}
|
|
878
|
-
);
|
|
662
|
+
ReactPerf.measureMethods(ReactCompositeComponentMixin, 'ReactCompositeComponent', {
|
|
663
|
+
mountComponent: 'mountComponent',
|
|
664
|
+
updateComponent: 'updateComponent',
|
|
665
|
+
_renderValidatedComponent: '_renderValidatedComponent'
|
|
666
|
+
});
|
|
879
667
|
|
|
880
668
|
var ReactCompositeComponent = {
|
|
881
669
|
|
|
@@ -883,4 +671,4 @@ var ReactCompositeComponent = {
|
|
|
883
671
|
|
|
884
672
|
};
|
|
885
673
|
|
|
886
|
-
module.exports = ReactCompositeComponent;
|
|
674
|
+
module.exports = ReactCompositeComponent;
|