react 0.14.9 → 15.0.0-rc.2
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/LICENSE +1 -1
- package/addons.js +2 -0
- package/dist/react-with-addons.js +4299 -4138
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4059 -3644
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +21 -7
- package/lib/CallbackQueue.js +12 -1
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +93 -60
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +15 -36
- package/lib/DOMPropertyOperations.js +40 -52
- package/lib/Danger.js +6 -7
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +20 -64
- package/lib/EventPluginRegistry.js +23 -2
- package/lib/EventPluginUtils.js +60 -35
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +1 -2
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +2 -3
- package/lib/MetaMatchers.js +2 -2
- package/lib/Object.assign.js +1 -1
- package/lib/OrderedMap.js +1 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +1 -13
- package/lib/ReactBrowserEventEmitter.js +16 -24
- package/lib/ReactCSSTransitionGroup.js +1 -2
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +14 -12
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +21 -70
- package/lib/ReactComponent.js +4 -5
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +3 -3
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +146 -55
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +26 -14
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +162 -231
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +71 -22
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +9 -8
- package/lib/ReactDOMSelect.js +38 -15
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +84 -43
- package/lib/ReactDOMTextarea.js +32 -5
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +59 -19
- package/lib/ReactDefaultPerfAnalysis.js +17 -9
- package/lib/ReactElement.js +60 -21
- package/lib/ReactElementValidator.js +2 -2
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +20 -75
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +2 -2
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +4 -6
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactIsomorphic.js +1 -1
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +74 -447
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +2 -2
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +1 -24
- package/lib/ReactOwner.js +5 -4
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +17 -6
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +16 -34
- package/lib/ReactServerRenderingTransaction.js +8 -26
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +30 -21
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +1 -1
- package/lib/ReactUpdateQueue.js +4 -63
- package/lib/ReactUpdates.js +19 -2
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -14
- package/lib/ResponderEventPlugin.js +53 -65
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +1 -1
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +56 -16
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +97 -17
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +1 -1
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +1 -1
- package/lib/accumulateInto.js +1 -1
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +3 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +1 -1
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +7 -9
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +5 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +6 -6
- package/lib/update.js +2 -2
- package/lib/validateDOMNesting.js +15 -11
- package/package.json +2 -2
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
package/lib/ReactComponent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
|
|
15
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
15
16
|
|
|
16
17
|
var canDefineProperty = require('./canDefineProperty');
|
|
17
18
|
var emptyObject = require('fbjs/lib/emptyObject');
|
|
@@ -60,6 +61,7 @@ ReactComponent.prototype.isReactComponent = {};
|
|
|
60
61
|
ReactComponent.prototype.setState = function (partialState, callback) {
|
|
61
62
|
!(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;
|
|
62
63
|
if (process.env.NODE_ENV !== 'production') {
|
|
64
|
+
ReactInstrumentation.debugTool.onSetState();
|
|
63
65
|
process.env.NODE_ENV !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : undefined;
|
|
64
66
|
}
|
|
65
67
|
this.updater.enqueueSetState(this, partialState);
|
|
@@ -96,11 +98,8 @@ ReactComponent.prototype.forceUpdate = function (callback) {
|
|
|
96
98
|
*/
|
|
97
99
|
if (process.env.NODE_ENV !== 'production') {
|
|
98
100
|
var deprecatedAPIs = {
|
|
99
|
-
getDOMNode: ['getDOMNode', 'Use ReactDOM.findDOMNode(component) instead.'],
|
|
100
101
|
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
101
|
-
|
|
102
|
-
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'],
|
|
103
|
-
setProps: ['setProps', 'Instead, call render again at the top level.']
|
|
102
|
+
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
|
104
103
|
};
|
|
105
104
|
var defineDeprecationWarning = function (methodName, info) {
|
|
106
105
|
if (canDefineProperty) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var DOMChildrenOperations = require('./DOMChildrenOperations');
|
|
14
15
|
var ReactDOMIDOperations = require('./ReactDOMIDOperations');
|
|
15
|
-
var
|
|
16
|
+
var ReactPerf = require('./ReactPerf');
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Abstracts away all functionality of the reconciler that requires knowledge of
|
|
@@ -23,7 +24,7 @@ var ReactComponentBrowserEnvironment = {
|
|
|
23
24
|
|
|
24
25
|
processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
replaceNodeWithMarkup: DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup,
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* If a particular environment requires that some resources be cleaned up,
|
|
@@ -32,10 +33,12 @@ var ReactComponentBrowserEnvironment = {
|
|
|
32
33
|
*
|
|
33
34
|
* @private
|
|
34
35
|
*/
|
|
35
|
-
unmountIDFromEnvironment: function (rootNodeID) {
|
|
36
|
-
ReactMount.purgeID(rootNodeID);
|
|
37
|
-
}
|
|
36
|
+
unmountIDFromEnvironment: function (rootNodeID) {}
|
|
38
37
|
|
|
39
38
|
};
|
|
40
39
|
|
|
40
|
+
ReactPerf.measureMethods(ReactComponentBrowserEnvironment, 'ReactComponentBrowserEnvironment', {
|
|
41
|
+
replaceNodeWithMarkup: 'replaceNodeWithMarkup'
|
|
42
|
+
});
|
|
43
|
+
|
|
41
44
|
module.exports = ReactComponentBrowserEnvironment;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014-
|
|
2
|
+
* Copyright 2014-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -28,7 +28,7 @@ var ReactComponentEnvironment = {
|
|
|
28
28
|
* Optionally injectable hook for swapping out mount images in the middle of
|
|
29
29
|
* the tree.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
replaceNodeWithMarkup: null,
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Optionally injectable hook for processing a queue of child updates. Will
|
|
@@ -40,7 +40,7 @@ var ReactComponentEnvironment = {
|
|
|
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
|
-
ReactComponentEnvironment.
|
|
43
|
+
ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup;
|
|
44
44
|
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
|
|
45
45
|
injected = true;
|
|
46
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -15,7 +15,7 @@ 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
|
|
18
|
-
* same result given the same props and state, provide this
|
|
18
|
+
* same result given the same props and state, provide this mixin for a
|
|
19
19
|
* considerable performance boost.
|
|
20
20
|
*
|
|
21
21
|
* Most React components have pure render functions.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
|
|
15
15
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
16
16
|
var ReactElement = require('./ReactElement');
|
|
17
|
+
var ReactErrorUtils = require('./ReactErrorUtils');
|
|
17
18
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
19
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
20
|
+
var ReactNodeTypes = require('./ReactNodeTypes');
|
|
18
21
|
var ReactPerf = require('./ReactPerf');
|
|
19
22
|
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
20
23
|
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
@@ -41,9 +44,17 @@ function getDeclarationErrorAddendum(component) {
|
|
|
41
44
|
function StatelessComponent(Component) {}
|
|
42
45
|
StatelessComponent.prototype.render = function () {
|
|
43
46
|
var Component = ReactInstanceMap.get(this)._currentElement.type;
|
|
44
|
-
|
|
47
|
+
var element = Component(this.props, this.context, this.updater);
|
|
48
|
+
warnIfInvalidElement(Component, element);
|
|
49
|
+
return element;
|
|
45
50
|
};
|
|
46
51
|
|
|
52
|
+
function warnIfInvalidElement(Component, element) {
|
|
53
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
54
|
+
process.env.NODE_ENV !== 'production' ? warning(element === null || element === false || ReactElement.isValidElement(element), '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
47
58
|
/**
|
|
48
59
|
* ------------------ The Life-Cycle of a Composite Component ------------------
|
|
49
60
|
*
|
|
@@ -95,6 +106,8 @@ var ReactCompositeComponentMixin = {
|
|
|
95
106
|
this._currentElement = element;
|
|
96
107
|
this._rootNodeID = null;
|
|
97
108
|
this._instance = null;
|
|
109
|
+
this._nativeParent = null;
|
|
110
|
+
this._nativeContainerInfo = null;
|
|
98
111
|
|
|
99
112
|
// See ReactUpdateQueue
|
|
100
113
|
this._pendingElement = null;
|
|
@@ -102,8 +115,8 @@ var ReactCompositeComponentMixin = {
|
|
|
102
115
|
this._pendingReplaceState = false;
|
|
103
116
|
this._pendingForceUpdate = false;
|
|
104
117
|
|
|
118
|
+
this._renderedNodeType = null;
|
|
105
119
|
this._renderedComponent = null;
|
|
106
|
-
|
|
107
120
|
this._context = null;
|
|
108
121
|
this._mountOrder = 0;
|
|
109
122
|
this._topLevelWrapper = null;
|
|
@@ -115,16 +128,19 @@ var ReactCompositeComponentMixin = {
|
|
|
115
128
|
/**
|
|
116
129
|
* Initializes the component, renders markup, and registers event listeners.
|
|
117
130
|
*
|
|
118
|
-
* @param {string} rootID DOM ID of the root node.
|
|
119
131
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
132
|
+
* @param {?object} nativeParent
|
|
133
|
+
* @param {?object} nativeContainerInfo
|
|
134
|
+
* @param {?object} context
|
|
120
135
|
* @return {?string} Rendered markup to be inserted into the DOM.
|
|
121
136
|
* @final
|
|
122
137
|
* @internal
|
|
123
138
|
*/
|
|
124
|
-
mountComponent: function (
|
|
139
|
+
mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
|
|
125
140
|
this._context = context;
|
|
126
141
|
this._mountOrder = nextMountID++;
|
|
127
|
-
this.
|
|
142
|
+
this._nativeParent = nativeParent;
|
|
143
|
+
this._nativeContainerInfo = nativeContainerInfo;
|
|
128
144
|
|
|
129
145
|
var publicProps = this._processProps(this._currentElement.props);
|
|
130
146
|
var publicContext = this._processContext(context);
|
|
@@ -135,13 +151,7 @@ var ReactCompositeComponentMixin = {
|
|
|
135
151
|
var inst;
|
|
136
152
|
var renderedElement;
|
|
137
153
|
|
|
138
|
-
|
|
139
|
-
// component, which is not newable. It might not be 100% reliable but is
|
|
140
|
-
// something we can do until we start detecting that Component extends
|
|
141
|
-
// React.Component. We already assume that typeof Component === 'function'.
|
|
142
|
-
var canInstantiate = ('prototype' in Component);
|
|
143
|
-
|
|
144
|
-
if (canInstantiate) {
|
|
154
|
+
if (Component.prototype && Component.prototype.isReactComponent) {
|
|
145
155
|
if (process.env.NODE_ENV !== 'production') {
|
|
146
156
|
ReactCurrentOwner.current = this;
|
|
147
157
|
try {
|
|
@@ -152,23 +162,36 @@ var ReactCompositeComponentMixin = {
|
|
|
152
162
|
} else {
|
|
153
163
|
inst = new Component(publicProps, publicContext, ReactUpdateQueue);
|
|
154
164
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
} else {
|
|
166
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
167
|
+
ReactCurrentOwner.current = this;
|
|
168
|
+
try {
|
|
169
|
+
inst = Component(publicProps, publicContext, ReactUpdateQueue);
|
|
170
|
+
} finally {
|
|
171
|
+
ReactCurrentOwner.current = null;
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
inst = Component(publicProps, publicContext, ReactUpdateQueue);
|
|
175
|
+
}
|
|
176
|
+
if (inst == null || inst.render == null) {
|
|
177
|
+
renderedElement = inst;
|
|
178
|
+
warnIfInvalidElement(Component, renderedElement);
|
|
179
|
+
!(inst === null || inst === false || ReactElement.isValidElement(inst)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : invariant(false) : undefined;
|
|
180
|
+
inst = new StatelessComponent(Component);
|
|
181
|
+
}
|
|
160
182
|
}
|
|
161
183
|
|
|
162
184
|
if (process.env.NODE_ENV !== 'production') {
|
|
163
185
|
// This will throw later in _renderValidatedComponent, but add an early
|
|
164
186
|
// warning now to help debugging
|
|
165
187
|
if (inst.render == null) {
|
|
166
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render
|
|
167
|
-
} else {
|
|
168
|
-
// We support ES6 inheriting from React.Component, the module pattern,
|
|
169
|
-
// and stateless components, but not ES6 classes that don't extend
|
|
170
|
-
process.env.NODE_ENV !== 'production' ? warning(Component.prototype && Component.prototype.isReactComponent || !canInstantiate || !(inst instanceof Component), '%s(...): React component classes must extend React.Component.', Component.displayName || Component.name || 'Component') : undefined;
|
|
188
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', Component.displayName || Component.name || 'Component') : undefined;
|
|
171
189
|
}
|
|
190
|
+
|
|
191
|
+
var propsMutated = inst.props !== publicProps;
|
|
192
|
+
var componentName = Component.displayName || Component.name || 'Component';
|
|
193
|
+
|
|
194
|
+
process.env.NODE_ENV !== 'production' ? warning(inst.props === undefined || !propsMutated, '%s(...): When calling super() in `%s`, make sure to pass ' + 'up the same props that your component\'s constructor was passed.', componentName, componentName) : undefined;
|
|
172
195
|
}
|
|
173
196
|
|
|
174
197
|
// These should be set up in the constructor, but as a convenience for
|
|
@@ -206,6 +229,46 @@ var ReactCompositeComponentMixin = {
|
|
|
206
229
|
this._pendingReplaceState = false;
|
|
207
230
|
this._pendingForceUpdate = false;
|
|
208
231
|
|
|
232
|
+
var markup;
|
|
233
|
+
if (inst.unstable_handleError) {
|
|
234
|
+
markup = this.performInitialMountWithErrorHandling(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
|
|
235
|
+
} else {
|
|
236
|
+
markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (inst.componentDidMount) {
|
|
240
|
+
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return markup;
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
performInitialMountWithErrorHandling: function (renderedElement, nativeParent, nativeContainerInfo, transaction, context) {
|
|
247
|
+
var markup;
|
|
248
|
+
var checkpoint = transaction.checkpoint();
|
|
249
|
+
try {
|
|
250
|
+
markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
|
|
251
|
+
} catch (e) {
|
|
252
|
+
// Roll back to checkpoint, handle error (which may add items to the transaction), and take a new checkpoint
|
|
253
|
+
transaction.rollback(checkpoint);
|
|
254
|
+
this._instance.unstable_handleError(e);
|
|
255
|
+
if (this._pendingStateQueue) {
|
|
256
|
+
this._instance.state = this._processPendingState(this._instance.props, this._instance.context);
|
|
257
|
+
}
|
|
258
|
+
checkpoint = transaction.checkpoint();
|
|
259
|
+
|
|
260
|
+
this._renderedComponent.unmountComponent(true);
|
|
261
|
+
transaction.rollback(checkpoint);
|
|
262
|
+
|
|
263
|
+
// Try again - we've informed the component about the error, so they can render an error message this time.
|
|
264
|
+
// If this throws again, the error will bubble up (and can be caught by a higher error boundary).
|
|
265
|
+
markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
|
|
266
|
+
}
|
|
267
|
+
return markup;
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
performInitialMount: function (renderedElement, nativeParent, nativeContainerInfo, transaction, context) {
|
|
271
|
+
var inst = this._instance;
|
|
209
272
|
if (inst.componentWillMount) {
|
|
210
273
|
inst.componentWillMount();
|
|
211
274
|
// When mounting, calls to `setState` by `componentWillMount` will set
|
|
@@ -220,32 +283,45 @@ var ReactCompositeComponentMixin = {
|
|
|
220
283
|
renderedElement = this._renderValidatedComponent();
|
|
221
284
|
}
|
|
222
285
|
|
|
286
|
+
this._renderedNodeType = ReactNodeTypes.getType(renderedElement);
|
|
223
287
|
this._renderedComponent = this._instantiateReactComponent(renderedElement);
|
|
224
288
|
|
|
225
|
-
var markup = ReactReconciler.mountComponent(this._renderedComponent,
|
|
226
|
-
if (inst.componentDidMount) {
|
|
227
|
-
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
|
|
228
|
-
}
|
|
289
|
+
var markup = ReactReconciler.mountComponent(this._renderedComponent, transaction, nativeParent, nativeContainerInfo, this._processChildContext(context));
|
|
229
290
|
|
|
230
291
|
return markup;
|
|
231
292
|
},
|
|
232
293
|
|
|
294
|
+
getNativeNode: function () {
|
|
295
|
+
return ReactReconciler.getNativeNode(this._renderedComponent);
|
|
296
|
+
},
|
|
297
|
+
|
|
233
298
|
/**
|
|
234
299
|
* Releases any resources allocated by `mountComponent`.
|
|
235
300
|
*
|
|
236
301
|
* @final
|
|
237
302
|
* @internal
|
|
238
303
|
*/
|
|
239
|
-
unmountComponent: function () {
|
|
304
|
+
unmountComponent: function (safely) {
|
|
305
|
+
if (!this._renderedComponent) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
240
308
|
var inst = this._instance;
|
|
241
309
|
|
|
242
310
|
if (inst.componentWillUnmount) {
|
|
243
|
-
|
|
311
|
+
if (safely) {
|
|
312
|
+
var name = this.getName() + '.componentWillUnmount()';
|
|
313
|
+
ReactErrorUtils.invokeGuardedCallback(name, inst.componentWillUnmount.bind(inst));
|
|
314
|
+
} else {
|
|
315
|
+
inst.componentWillUnmount();
|
|
316
|
+
}
|
|
244
317
|
}
|
|
245
318
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
319
|
+
if (this._renderedComponent) {
|
|
320
|
+
ReactReconciler.unmountComponent(this._renderedComponent, safely);
|
|
321
|
+
this._renderedNodeType = null;
|
|
322
|
+
this._renderedComponent = null;
|
|
323
|
+
this._instance = null;
|
|
324
|
+
}
|
|
249
325
|
|
|
250
326
|
// Reset pending fields
|
|
251
327
|
// Even if this component is scheduled for another update in ReactUpdates,
|
|
@@ -283,13 +359,12 @@ var ReactCompositeComponentMixin = {
|
|
|
283
359
|
* @private
|
|
284
360
|
*/
|
|
285
361
|
_maskContext: function (context) {
|
|
286
|
-
var maskedContext = null;
|
|
287
362
|
var Component = this._currentElement.type;
|
|
288
363
|
var contextTypes = Component.contextTypes;
|
|
289
364
|
if (!contextTypes) {
|
|
290
365
|
return emptyObject;
|
|
291
366
|
}
|
|
292
|
-
maskedContext = {};
|
|
367
|
+
var maskedContext = {};
|
|
293
368
|
for (var contextName in contextTypes) {
|
|
294
369
|
maskedContext[contextName] = context[contextName];
|
|
295
370
|
}
|
|
@@ -323,7 +398,13 @@ var ReactCompositeComponentMixin = {
|
|
|
323
398
|
_processChildContext: function (currentContext) {
|
|
324
399
|
var Component = this._currentElement.type;
|
|
325
400
|
var inst = this._instance;
|
|
401
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
402
|
+
ReactInstrumentation.debugTool.onBeginProcessingChildContext();
|
|
403
|
+
}
|
|
326
404
|
var childContext = inst.getChildContext && inst.getChildContext();
|
|
405
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
406
|
+
ReactInstrumentation.debugTool.onEndProcessingChildContext();
|
|
407
|
+
}
|
|
327
408
|
if (childContext) {
|
|
328
409
|
!(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;
|
|
329
410
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -375,7 +456,7 @@ var ReactCompositeComponentMixin = {
|
|
|
375
456
|
// This is intentionally an invariant that gets caught. It's the same
|
|
376
457
|
// behavior as without this statement except with a better message.
|
|
377
458
|
!(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;
|
|
378
|
-
error = propTypes[propName](props, propName, componentName, location
|
|
459
|
+
error = propTypes[propName](props, propName, componentName, location);
|
|
379
460
|
} catch (ex) {
|
|
380
461
|
error = ex;
|
|
381
462
|
}
|
|
@@ -414,7 +495,7 @@ var ReactCompositeComponentMixin = {
|
|
|
414
495
|
*/
|
|
415
496
|
performUpdateIfNecessary: function (transaction) {
|
|
416
497
|
if (this._pendingElement != null) {
|
|
417
|
-
ReactReconciler.receiveComponent(this, this._pendingElement
|
|
498
|
+
ReactReconciler.receiveComponent(this, this._pendingElement, transaction, this._context);
|
|
418
499
|
}
|
|
419
500
|
|
|
420
501
|
if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
|
|
@@ -439,10 +520,18 @@ var ReactCompositeComponentMixin = {
|
|
|
439
520
|
*/
|
|
440
521
|
updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
|
|
441
522
|
var inst = this._instance;
|
|
442
|
-
|
|
443
|
-
var nextContext
|
|
523
|
+
var willReceive = false;
|
|
524
|
+
var nextContext;
|
|
444
525
|
var nextProps;
|
|
445
526
|
|
|
527
|
+
// Determine if the context has changed or not
|
|
528
|
+
if (this._context === nextUnmaskedContext) {
|
|
529
|
+
nextContext = inst.context;
|
|
530
|
+
} else {
|
|
531
|
+
nextContext = this._processContext(nextUnmaskedContext);
|
|
532
|
+
willReceive = true;
|
|
533
|
+
}
|
|
534
|
+
|
|
446
535
|
// Distinguish between a props update versus a simple state update
|
|
447
536
|
if (prevParentElement === nextParentElement) {
|
|
448
537
|
// Skip checking prop types again -- we don't read inst.props to avoid
|
|
@@ -450,13 +539,14 @@ var ReactCompositeComponentMixin = {
|
|
|
450
539
|
nextProps = nextParentElement.props;
|
|
451
540
|
} else {
|
|
452
541
|
nextProps = this._processProps(nextParentElement.props);
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
// immediately reconciled instead of waiting for the next batch.
|
|
542
|
+
willReceive = true;
|
|
543
|
+
}
|
|
456
544
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
545
|
+
// An update here will schedule an update but immediately set
|
|
546
|
+
// _pendingStateQueue which will ensure that any state updates gets
|
|
547
|
+
// immediately reconciled instead of waiting for the next batch.
|
|
548
|
+
if (willReceive && inst.componentWillReceiveProps) {
|
|
549
|
+
inst.componentWillReceiveProps(nextProps, nextContext);
|
|
460
550
|
}
|
|
461
551
|
|
|
462
552
|
var nextState = this._processPendingState(nextProps, nextContext);
|
|
@@ -464,7 +554,7 @@ var ReactCompositeComponentMixin = {
|
|
|
464
554
|
var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext);
|
|
465
555
|
|
|
466
556
|
if (process.env.NODE_ENV !== 'production') {
|
|
467
|
-
process.env.NODE_ENV !== 'production' ? warning(
|
|
557
|
+
process.env.NODE_ENV !== 'production' ? warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : undefined;
|
|
468
558
|
}
|
|
469
559
|
|
|
470
560
|
if (shouldUpdate) {
|
|
@@ -561,22 +651,23 @@ var ReactCompositeComponentMixin = {
|
|
|
561
651
|
if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
|
|
562
652
|
ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
|
|
563
653
|
} else {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
var prevComponentID = prevComponentInstance._rootNodeID;
|
|
567
|
-
ReactReconciler.unmountComponent(prevComponentInstance);
|
|
654
|
+
var oldNativeNode = ReactReconciler.getNativeNode(prevComponentInstance);
|
|
655
|
+
ReactReconciler.unmountComponent(prevComponentInstance, false);
|
|
568
656
|
|
|
657
|
+
this._renderedNodeType = ReactNodeTypes.getType(nextRenderedElement);
|
|
569
658
|
this._renderedComponent = this._instantiateReactComponent(nextRenderedElement);
|
|
570
|
-
var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent,
|
|
571
|
-
this.
|
|
659
|
+
var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, transaction, this._nativeParent, this._nativeContainerInfo, this._processChildContext(context));
|
|
660
|
+
this._replaceNodeWithMarkup(oldNativeNode, nextMarkup);
|
|
572
661
|
}
|
|
573
662
|
},
|
|
574
663
|
|
|
575
664
|
/**
|
|
665
|
+
* Overridden in shallow rendering.
|
|
666
|
+
*
|
|
576
667
|
* @protected
|
|
577
668
|
*/
|
|
578
|
-
|
|
579
|
-
ReactComponentEnvironment.
|
|
669
|
+
_replaceNodeWithMarkup: function (oldNativeNode, nextMarkup) {
|
|
670
|
+
ReactComponentEnvironment.replaceNodeWithMarkup(oldNativeNode, nextMarkup);
|
|
580
671
|
},
|
|
581
672
|
|
|
582
673
|
/**
|
|
@@ -587,7 +678,7 @@ var ReactCompositeComponentMixin = {
|
|
|
587
678
|
var renderedComponent = inst.render();
|
|
588
679
|
if (process.env.NODE_ENV !== 'production') {
|
|
589
680
|
// We allow auto-mocks to proceed as if they're returning null.
|
|
590
|
-
if (
|
|
681
|
+
if (renderedComponent === undefined && inst.render._isMockFunction) {
|
|
591
682
|
// This is probably bad practice. Consider warning here and
|
|
592
683
|
// deprecating this convenience.
|
|
593
684
|
renderedComponent = null;
|
|
@@ -610,7 +701,7 @@ var ReactCompositeComponentMixin = {
|
|
|
610
701
|
}
|
|
611
702
|
!(
|
|
612
703
|
// TODO: An `isValidNode` function would probably be more appropriate
|
|
613
|
-
renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid
|
|
704
|
+
renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
|
|
614
705
|
return renderedComponent;
|
|
615
706
|
},
|
|
616
707
|
|