react 15.3.2 → 15.4.0-rc.4
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/dist/react-with-addons.js +3864 -21390
- package/dist/react-with-addons.min.js +3 -6
- package/dist/react.js +2639 -19486
- package/dist/react.min.js +2 -6
- package/lib/KeyEscapeUtils.js +0 -1
- package/lib/LinkedStateMixin.js +1 -3
- package/lib/PooledClass.js +3 -1
- package/lib/React.js +0 -1
- package/lib/ReactAddonsDOMDependencies.js +35 -0
- package/lib/ReactAddonsDOMDependenciesUMDShim.js +31 -0
- package/lib/ReactCSSTransitionGroup.js +60 -43
- package/lib/ReactCSSTransitionGroupChild.js +2 -3
- package/lib/ReactChildren.js +0 -1
- package/lib/ReactClass.js +38 -54
- package/lib/ReactComponent.js +0 -1
- package/lib/ReactComponentTreeDevtool.js +0 -1
- package/lib/ReactComponentTreeHook.js +84 -101
- package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +4 -7
- package/lib/ReactComponentWithPureRenderMixin.js +0 -1
- package/lib/ReactCurrentOwner.js +1 -2
- package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +5 -4
- package/lib/ReactDOMFactories.js +0 -1
- package/lib/ReactElement.js +6 -14
- package/lib/ReactElementSymbol.js +19 -0
- package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +3 -9
- package/lib/ReactElementValidator.js +1 -3
- package/lib/ReactFragment.js +0 -1
- package/lib/ReactLink.js +0 -1
- package/lib/ReactNoopUpdateQueue.js +0 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +2 -12
- package/lib/ReactPropTypes.js +5 -3
- package/lib/ReactPropTypesSecret.js +1 -1
- package/lib/ReactPureComponent.js +0 -1
- package/lib/ReactStateSetters.js +0 -1
- package/lib/ReactTransitionChildMapping.js +0 -1
- package/lib/ReactTransitionEvents.js +1 -2
- package/lib/ReactTransitionGroup.js +145 -142
- package/lib/ReactUMDEntry.js +11 -6
- package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +3 -6
- package/lib/ReactVersion.js +1 -2
- package/lib/ReactWithAddons.js +15 -3
- package/lib/ReactWithAddonsUMDEntry.js +11 -6
- package/lib/canDefineProperty.js +2 -1
- package/lib/checkReactTypeSpec.js +0 -1
- package/lib/deprecated.js +0 -1
- package/lib/flattenChildren.js +0 -1
- package/lib/getIteratorFn.js +0 -1
- package/lib/onlyChild.js +0 -1
- package/lib/reactProdInvariant.js +0 -1
- package/lib/shallowCompare.js +1 -2
- package/lib/sliceChildren.js +0 -1
- package/lib/traverseAllChildren.js +11 -3
- package/lib/update.js +6 -8
- package/package.json +1 -1
- package/lib/AutoFocusUtils.js +0 -24
- package/lib/BeforeInputEventPlugin.js +0 -390
- package/lib/CSSProperty.js +0 -148
- package/lib/CSSPropertyOperations.js +0 -205
- package/lib/CallbackQueue.js +0 -106
- package/lib/ChangeEventPlugin.js +0 -325
- package/lib/DOMChildrenOperations.js +0 -194
- package/lib/DOMLazyTree.js +0 -118
- package/lib/DOMProperty.js +0 -206
- package/lib/DOMPropertyOperations.js +0 -221
- package/lib/Danger.js +0 -48
- package/lib/DefaultEventPluginOrder.js +0 -27
- package/lib/DisabledInputUtils.js +0 -50
- package/lib/EnterLeaveEventPlugin.js +0 -105
- package/lib/EventConstants.js +0 -97
- package/lib/EventPluginHub.js +0 -251
- package/lib/EventPluginRegistry.js +0 -247
- package/lib/EventPluginUtils.js +0 -229
- package/lib/EventPropagators.js +0 -137
- package/lib/FallbackCompositionState.js +0 -95
- package/lib/HTMLDOMPropertyConfig.js +0 -212
- package/lib/LinkedValueUtils.js +0 -136
- package/lib/NativeMethodsMixin.js +0 -167
- package/lib/ReactBrowserEventEmitter.js +0 -330
- package/lib/ReactChildReconciler.js +0 -154
- package/lib/ReactChildrenMutationWarningHook.js +0 -54
- package/lib/ReactComponentBrowserEnvironment.js +0 -30
- package/lib/ReactComponentEnvironment.js +0 -45
- package/lib/ReactComponentTreeTestUtils.js +0 -87
- package/lib/ReactCompositeComponent.js +0 -904
- package/lib/ReactDOM.js +0 -110
- package/lib/ReactDOMButton.js +0 -24
- package/lib/ReactDOMComponent.js +0 -1006
- package/lib/ReactDOMComponentTree.js +0 -188
- package/lib/ReactDOMContainerInfo.js +0 -33
- package/lib/ReactDOMEmptyComponent.js +0 -60
- package/lib/ReactDOMFiber.js +0 -76
- package/lib/ReactDOMIDOperations.js +0 -34
- package/lib/ReactDOMInput.js +0 -269
- package/lib/ReactDOMNullInputValuePropHook.js +0 -43
- package/lib/ReactDOMOption.js +0 -123
- package/lib/ReactDOMSelect.js +0 -201
- package/lib/ReactDOMSelection.js +0 -212
- package/lib/ReactDOMServer.js +0 -26
- package/lib/ReactDOMTextComponent.js +0 -164
- package/lib/ReactDOMTextarea.js +0 -155
- package/lib/ReactDOMTreeTraversal.js +0 -136
- package/lib/ReactDOMUnknownPropertyHook.js +0 -112
- package/lib/ReactDebugTool.js +0 -301
- package/lib/ReactDefaultBatchingStrategy.js +0 -68
- package/lib/ReactDefaultInjection.js +0 -84
- package/lib/ReactEmptyComponent.js +0 -30
- package/lib/ReactErrorUtils.js +0 -76
- package/lib/ReactEventEmitterMixin.js +0 -33
- package/lib/ReactEventListener.js +0 -157
- package/lib/ReactFeatureFlags.js +0 -22
- package/lib/ReactHostComponent.js +0 -76
- package/lib/ReactHostOperationHistoryHook.js +0 -37
- package/lib/ReactInjection.js +0 -36
- package/lib/ReactInputSelection.js +0 -124
- package/lib/ReactInstanceHandles.js +0 -302
- package/lib/ReactInstanceMap.js +0 -48
- package/lib/ReactInstrumentation.js +0 -21
- package/lib/ReactInvalidSetStateWarningHook.js +0 -36
- package/lib/ReactMarkupChecksum.js +0 -50
- package/lib/ReactMount.js +0 -534
- package/lib/ReactMultiChild.js +0 -451
- package/lib/ReactMultiChildUpdateTypes.js +0 -32
- package/lib/ReactNative.js +0 -71
- package/lib/ReactNativeAttributePayload.js +0 -371
- package/lib/ReactNativeBaseComponent.js +0 -198
- package/lib/ReactNativeBridgeEventPlugin.js +0 -60
- package/lib/ReactNativeComponentEnvironment.js +0 -31
- package/lib/ReactNativeComponentTree.js +0 -68
- package/lib/ReactNativeContainerInfo.js +0 -21
- package/lib/ReactNativeDOMIDOperations.js +0 -79
- package/lib/ReactNativeDefaultInjection.js +0 -101
- package/lib/ReactNativeEventEmitter.js +0 -191
- package/lib/ReactNativeEventPluginOrder.js +0 -16
- package/lib/ReactNativeGlobalResponderHandler.js +0 -25
- package/lib/ReactNativeMount.js +0 -193
- package/lib/ReactNativePropRegistry.js +0 -52
- package/lib/ReactNativeReconcileTransaction.js +0 -129
- package/lib/ReactNativeTagHandles.js +0 -56
- package/lib/ReactNativeTextComponent.js +0 -71
- package/lib/ReactNativeTreeTraversal.js +0 -127
- package/lib/ReactNodeTypes.js +0 -40
- package/lib/ReactNoop.js +0 -173
- package/lib/ReactOwner.js +0 -94
- package/lib/ReactPerf.js +0 -494
- package/lib/ReactReconcileTransaction.js +0 -178
- package/lib/ReactReconciler.js +0 -168
- package/lib/ReactRef.js +0 -80
- package/lib/ReactServerBatchingStrategy.js +0 -22
- package/lib/ReactServerRendering.js +0 -90
- package/lib/ReactServerRenderingTransaction.js +0 -90
- package/lib/ReactServerUpdateQueue.js +0 -141
- package/lib/ReactSimpleEmptyComponent.js +0 -37
- package/lib/ReactTestMount.js +0 -126
- package/lib/ReactTestReconcileTransaction.js +0 -121
- package/lib/ReactTestRenderer.js +0 -144
- package/lib/ReactTestUtils.js +0 -518
- package/lib/ReactUpdateQueue.js +0 -226
- package/lib/ReactUpdates.js +0 -251
- package/lib/ResponderEventPlugin.js +0 -510
- package/lib/ResponderSyntheticEvent.js +0 -39
- package/lib/ResponderTouchHistoryStore.js +0 -184
- package/lib/SVGDOMPropertyConfig.js +0 -302
- package/lib/SelectEventPlugin.js +0 -196
- package/lib/SimpleEventPlugin.js +0 -635
- package/lib/SyntheticAnimationEvent.js +0 -39
- package/lib/SyntheticClipboardEvent.js +0 -38
- package/lib/SyntheticCompositionEvent.js +0 -36
- package/lib/SyntheticDragEvent.js +0 -36
- package/lib/SyntheticEvent.js +0 -268
- package/lib/SyntheticFocusEvent.js +0 -36
- package/lib/SyntheticInputEvent.js +0 -37
- package/lib/SyntheticKeyboardEvent.js +0 -84
- package/lib/SyntheticMouseEvent.js +0 -72
- package/lib/SyntheticTouchEvent.js +0 -45
- package/lib/SyntheticTransitionEvent.js +0 -39
- package/lib/SyntheticUIEvent.js +0 -59
- package/lib/SyntheticWheelEvent.js +0 -54
- package/lib/TapEventPlugin.js +0 -110
- package/lib/TouchHistoryMath.js +0 -99
- package/lib/Transaction.js +0 -233
- package/lib/ViewportMetrics.js +0 -27
- package/lib/accumulate.js +0 -46
- package/lib/accumulateInto.js +0 -58
- package/lib/adler32.js +0 -44
- package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
- package/lib/createReactNativeComponentClass.js +0 -42
- package/lib/dangerousStyleValue.js +0 -79
- package/lib/escapeTextContentForBrowser.js +0 -123
- package/lib/findDOMNode.js +0 -60
- package/lib/findNodeHandle.js +0 -91
- package/lib/forEachAccumulated.js +0 -31
- package/lib/getEventCharCode.js +0 -50
- package/lib/getEventKey.js +0 -102
- package/lib/getEventModifierState.js +0 -43
- package/lib/getEventTarget.js +0 -35
- package/lib/getHostComponentFromComposite.js +0 -30
- package/lib/getNodeForCharacterOffset.js +0 -74
- package/lib/getTestDocument.js +0 -21
- package/lib/getTextContentAccessor.js +0 -33
- package/lib/getVendorPrefixedEventName.js +0 -101
- package/lib/instantiateReactComponent.js +0 -119
- package/lib/isEventSupported.js +0 -60
- package/lib/isTextInputElement.js +0 -51
- package/lib/quoteAttributeValueForBrowser.js +0 -26
- package/lib/reactComponentExpect.js +0 -217
- package/lib/setInnerHTML.js +0 -98
- package/lib/setTextContent.js +0 -48
- package/lib/shouldUpdateReactComponent.js +0 -42
- package/lib/validateDOMNesting.js +0 -382
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2014-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
-
*
|
|
9
|
-
* @providesModule ReactChildReconciler
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var ReactReconciler = require('./ReactReconciler');
|
|
15
|
-
|
|
16
|
-
var instantiateReactComponent = require('./instantiateReactComponent');
|
|
17
|
-
var KeyEscapeUtils = require('./KeyEscapeUtils');
|
|
18
|
-
var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
|
|
19
|
-
var traverseAllChildren = require('./traverseAllChildren');
|
|
20
|
-
var warning = require('fbjs/lib/warning');
|
|
21
|
-
|
|
22
|
-
var ReactComponentTreeHook;
|
|
23
|
-
|
|
24
|
-
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
|
|
25
|
-
// Temporary hack.
|
|
26
|
-
// Inline requires don't work well with Jest:
|
|
27
|
-
// https://github.com/facebook/react/issues/7240
|
|
28
|
-
// Remove the inline requires when we don't need them anymore:
|
|
29
|
-
// https://github.com/facebook/react/pull/7178
|
|
30
|
-
ReactComponentTreeHook = require('./ReactComponentTreeHook');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function instantiateChild(childInstances, child, name, selfDebugID) {
|
|
34
|
-
// We found a component instance.
|
|
35
|
-
var keyUnique = childInstances[name] === undefined;
|
|
36
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
37
|
-
if (!ReactComponentTreeHook) {
|
|
38
|
-
ReactComponentTreeHook = require('./ReactComponentTreeHook');
|
|
39
|
-
}
|
|
40
|
-
if (!keyUnique) {
|
|
41
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeHook.getStackAddendumByID(selfDebugID)) : void 0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (child != null && keyUnique) {
|
|
45
|
-
childInstances[name] = instantiateReactComponent(child, true);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* ReactChildReconciler provides helpers for initializing or updating a set of
|
|
51
|
-
* children. Its output is suitable for passing it onto ReactMultiChild which
|
|
52
|
-
* does diffed reordering and insertion.
|
|
53
|
-
*/
|
|
54
|
-
var ReactChildReconciler = {
|
|
55
|
-
/**
|
|
56
|
-
* Generates a "mount image" for each of the supplied children. In the case
|
|
57
|
-
* of `ReactDOMComponent`, a mount image is a string of markup.
|
|
58
|
-
*
|
|
59
|
-
* @param {?object} nestedChildNodes Nested child maps.
|
|
60
|
-
* @return {?object} A set of child instances.
|
|
61
|
-
* @internal
|
|
62
|
-
*/
|
|
63
|
-
instantiateChildren: function (nestedChildNodes, transaction, context, selfDebugID // 0 in production and for roots
|
|
64
|
-
) {
|
|
65
|
-
if (nestedChildNodes == null) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
var childInstances = {};
|
|
69
|
-
|
|
70
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
71
|
-
traverseAllChildren(nestedChildNodes, function (childInsts, child, name) {
|
|
72
|
-
return instantiateChild(childInsts, child, name, selfDebugID);
|
|
73
|
-
}, childInstances);
|
|
74
|
-
} else {
|
|
75
|
-
traverseAllChildren(nestedChildNodes, instantiateChild, childInstances);
|
|
76
|
-
}
|
|
77
|
-
return childInstances;
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Updates the rendered children and returns a new set of children.
|
|
82
|
-
*
|
|
83
|
-
* @param {?object} prevChildren Previously initialized set of children.
|
|
84
|
-
* @param {?object} nextChildren Flat child element maps.
|
|
85
|
-
* @param {ReactReconcileTransaction} transaction
|
|
86
|
-
* @param {object} context
|
|
87
|
-
* @return {?object} A new set of child instances.
|
|
88
|
-
* @internal
|
|
89
|
-
*/
|
|
90
|
-
updateChildren: function (prevChildren, nextChildren, mountImages, removedNodes, transaction, hostParent, hostContainerInfo, context, selfDebugID // 0 in production and for roots
|
|
91
|
-
) {
|
|
92
|
-
// We currently don't have a way to track moves here but if we use iterators
|
|
93
|
-
// instead of for..in we can zip the iterators and check if an item has
|
|
94
|
-
// moved.
|
|
95
|
-
// TODO: If nothing has changed, return the prevChildren object so that we
|
|
96
|
-
// can quickly bailout if nothing has changed.
|
|
97
|
-
if (!nextChildren && !prevChildren) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
var name;
|
|
101
|
-
var prevChild;
|
|
102
|
-
for (name in nextChildren) {
|
|
103
|
-
if (!nextChildren.hasOwnProperty(name)) {
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
prevChild = prevChildren && prevChildren[name];
|
|
107
|
-
var prevElement = prevChild && prevChild._currentElement;
|
|
108
|
-
var nextElement = nextChildren[name];
|
|
109
|
-
if (prevChild != null && shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
110
|
-
ReactReconciler.receiveComponent(prevChild, nextElement, transaction, context);
|
|
111
|
-
nextChildren[name] = prevChild;
|
|
112
|
-
} else {
|
|
113
|
-
if (prevChild) {
|
|
114
|
-
removedNodes[name] = ReactReconciler.getHostNode(prevChild);
|
|
115
|
-
ReactReconciler.unmountComponent(prevChild, false);
|
|
116
|
-
}
|
|
117
|
-
// The child must be instantiated before it's mounted.
|
|
118
|
-
var nextChildInstance = instantiateReactComponent(nextElement, true);
|
|
119
|
-
nextChildren[name] = nextChildInstance;
|
|
120
|
-
// Creating mount image now ensures refs are resolved in right order
|
|
121
|
-
// (see https://github.com/facebook/react/pull/7101 for explanation).
|
|
122
|
-
var nextChildMountImage = ReactReconciler.mountComponent(nextChildInstance, transaction, hostParent, hostContainerInfo, context, selfDebugID);
|
|
123
|
-
mountImages.push(nextChildMountImage);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// Unmount children that are no longer present.
|
|
127
|
-
for (name in prevChildren) {
|
|
128
|
-
if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
129
|
-
prevChild = prevChildren[name];
|
|
130
|
-
removedNodes[name] = ReactReconciler.getHostNode(prevChild);
|
|
131
|
-
ReactReconciler.unmountComponent(prevChild, false);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Unmounts all rendered children. This should be used to clean up children
|
|
138
|
-
* when this component is unmounted.
|
|
139
|
-
*
|
|
140
|
-
* @param {?object} renderedChildren Previously initialized set of children.
|
|
141
|
-
* @internal
|
|
142
|
-
*/
|
|
143
|
-
unmountChildren: function (renderedChildren, safely) {
|
|
144
|
-
for (var name in renderedChildren) {
|
|
145
|
-
if (renderedChildren.hasOwnProperty(name)) {
|
|
146
|
-
var renderedChild = renderedChildren[name];
|
|
147
|
-
ReactReconciler.unmountComponent(renderedChild, safely);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
module.exports = ReactChildReconciler;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
-
*
|
|
9
|
-
* @providesModule ReactChildrenMutationWarningHook
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var ReactComponentTreeHook = require('./ReactComponentTreeHook');
|
|
15
|
-
|
|
16
|
-
var warning = require('fbjs/lib/warning');
|
|
17
|
-
|
|
18
|
-
function handleElement(debugID, element) {
|
|
19
|
-
if (element == null) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (element._shadowChildren === undefined) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (element._shadowChildren === element.props.children) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
var isMutated = false;
|
|
29
|
-
if (Array.isArray(element._shadowChildren)) {
|
|
30
|
-
if (element._shadowChildren.length === element.props.children.length) {
|
|
31
|
-
for (var i = 0; i < element._shadowChildren.length; i++) {
|
|
32
|
-
if (element._shadowChildren[i] !== element.props.children[i]) {
|
|
33
|
-
isMutated = true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
isMutated = true;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (!Array.isArray(element._shadowChildren) || isMutated) {
|
|
41
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Component\'s children should not be mutated.%s', ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var ReactChildrenMutationWarningHook = {
|
|
46
|
-
onMountComponent: function (debugID) {
|
|
47
|
-
handleElement(debugID, ReactComponentTreeHook.getElement(debugID));
|
|
48
|
-
},
|
|
49
|
-
onUpdateComponent: function (debugID) {
|
|
50
|
-
handleElement(debugID, ReactComponentTreeHook.getElement(debugID));
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
module.exports = ReactChildrenMutationWarningHook;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
-
*
|
|
9
|
-
* @providesModule ReactComponentBrowserEnvironment
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var DOMChildrenOperations = require('./DOMChildrenOperations');
|
|
15
|
-
var ReactDOMIDOperations = require('./ReactDOMIDOperations');
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Abstracts away all functionality of the reconciler that requires knowledge of
|
|
19
|
-
* the browser context. TODO: These callers should be refactored to avoid the
|
|
20
|
-
* need for this injection.
|
|
21
|
-
*/
|
|
22
|
-
var ReactComponentBrowserEnvironment = {
|
|
23
|
-
|
|
24
|
-
processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
|
|
25
|
-
|
|
26
|
-
replaceNodeWithMarkup: DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
module.exports = ReactComponentBrowserEnvironment;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2014-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
-
*
|
|
9
|
-
* @providesModule ReactComponentEnvironment
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
-
|
|
16
|
-
var invariant = require('fbjs/lib/invariant');
|
|
17
|
-
|
|
18
|
-
var injected = false;
|
|
19
|
-
|
|
20
|
-
var ReactComponentEnvironment = {
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Optionally injectable hook for swapping out mount images in the middle of
|
|
24
|
-
* the tree.
|
|
25
|
-
*/
|
|
26
|
-
replaceNodeWithMarkup: null,
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Optionally injectable hook for processing a queue of child updates. Will
|
|
30
|
-
* later move into MultiChildComponents.
|
|
31
|
-
*/
|
|
32
|
-
processChildrenUpdates: null,
|
|
33
|
-
|
|
34
|
-
injection: {
|
|
35
|
-
injectEnvironment: function (environment) {
|
|
36
|
-
!!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : _prodInvariant('104') : void 0;
|
|
37
|
-
ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup;
|
|
38
|
-
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
|
|
39
|
-
injected = true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
module.exports = ReactComponentEnvironment;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2016-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
-
*
|
|
9
|
-
* @providesModule ReactComponentTreeTestUtils
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var _assign = require('object-assign');
|
|
15
|
-
|
|
16
|
-
var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
17
|
-
|
|
18
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
|
|
20
|
-
var ReactComponentTreeHook = require('./ReactComponentTreeHook');
|
|
21
|
-
|
|
22
|
-
function getRootDisplayNames() {
|
|
23
|
-
return ReactComponentTreeHook.getRootIDs().map(ReactComponentTreeHook.getDisplayName);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getRegisteredDisplayNames() {
|
|
27
|
-
return ReactComponentTreeHook.getRegisteredIDs().map(ReactComponentTreeHook.getDisplayName);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function expectTree(rootID, expectedTree, parentPath) {
|
|
31
|
-
var displayName = ReactComponentTreeHook.getDisplayName(rootID);
|
|
32
|
-
var ownerID = ReactComponentTreeHook.getOwnerID(rootID);
|
|
33
|
-
var parentID = ReactComponentTreeHook.getParentID(rootID);
|
|
34
|
-
var childIDs = ReactComponentTreeHook.getChildIDs(rootID);
|
|
35
|
-
var text = ReactComponentTreeHook.getText(rootID);
|
|
36
|
-
var element = ReactComponentTreeHook.getElement(rootID);
|
|
37
|
-
var path = parentPath ? parentPath + ' > ' + displayName : displayName;
|
|
38
|
-
|
|
39
|
-
function expectEqual(actual, expected, name) {
|
|
40
|
-
// Get Jasmine to print descriptive error messages.
|
|
41
|
-
// We pass path so that we know where the mismatch occurred.
|
|
42
|
-
expect(_defineProperty({
|
|
43
|
-
path: path
|
|
44
|
-
}, name, actual)).toEqual(_defineProperty({
|
|
45
|
-
path: path
|
|
46
|
-
}, name, expected));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (expectedTree.parentDisplayName !== undefined) {
|
|
50
|
-
expectEqual(ReactComponentTreeHook.getDisplayName(parentID), expectedTree.parentDisplayName, 'parentDisplayName');
|
|
51
|
-
}
|
|
52
|
-
if (expectedTree.ownerDisplayName !== undefined) {
|
|
53
|
-
expectEqual(ReactComponentTreeHook.getDisplayName(ownerID), expectedTree.ownerDisplayName, 'ownerDisplayName');
|
|
54
|
-
}
|
|
55
|
-
if (expectedTree.parentID !== undefined) {
|
|
56
|
-
expectEqual(parentID, expectedTree.parentID, 'parentID');
|
|
57
|
-
}
|
|
58
|
-
if (expectedTree.text !== undefined) {
|
|
59
|
-
expectEqual(text, expectedTree.text, 'text');
|
|
60
|
-
expectEqual('' + element, expectedTree.text, 'element.toString()');
|
|
61
|
-
} else {
|
|
62
|
-
expectEqual(text, null, 'text');
|
|
63
|
-
}
|
|
64
|
-
if (expectedTree.element !== undefined) {
|
|
65
|
-
// TODO: Comparing elements makes tests run out of memory on errors.
|
|
66
|
-
// For now, compare just types.
|
|
67
|
-
expectEqual(element && element.type, expectedTree.element && expectedTree.element.type, 'element.type');
|
|
68
|
-
} else if (text == null) {
|
|
69
|
-
expectEqual(typeof element, 'object', 'typeof element');
|
|
70
|
-
}
|
|
71
|
-
if (expectedTree.children !== undefined) {
|
|
72
|
-
expectEqual(childIDs.length, expectedTree.children.length, 'children.length');
|
|
73
|
-
for (var i = 0; i < childIDs.length; i++) {
|
|
74
|
-
expectTree(childIDs[i], _extends({ parentID: rootID }, expectedTree.children[i]), path);
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
expectEqual(childIDs, [], 'childIDs');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
var ReactComponentTreeTestUtils = {
|
|
82
|
-
expectTree: expectTree,
|
|
83
|
-
getRootDisplayNames: getRootDisplayNames,
|
|
84
|
-
getRegisteredDisplayNames: getRegisteredDisplayNames
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
module.exports = ReactComponentTreeTestUtils;
|
|
@@ -1,904 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
-
*
|
|
9
|
-
* @providesModule ReactCompositeComponent
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var _prodInvariant = require('./reactProdInvariant'),
|
|
15
|
-
_assign = require('object-assign');
|
|
16
|
-
|
|
17
|
-
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
|
|
18
|
-
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
19
|
-
var ReactElement = require('./ReactElement');
|
|
20
|
-
var ReactErrorUtils = require('./ReactErrorUtils');
|
|
21
|
-
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
22
|
-
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
23
|
-
var ReactNodeTypes = require('./ReactNodeTypes');
|
|
24
|
-
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
25
|
-
var ReactReconciler = require('./ReactReconciler');
|
|
26
|
-
|
|
27
|
-
var checkReactTypeSpec = require('./checkReactTypeSpec');
|
|
28
|
-
var emptyObject = require('fbjs/lib/emptyObject');
|
|
29
|
-
var invariant = require('fbjs/lib/invariant');
|
|
30
|
-
var shallowEqual = require('fbjs/lib/shallowEqual');
|
|
31
|
-
var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
|
|
32
|
-
var warning = require('fbjs/lib/warning');
|
|
33
|
-
|
|
34
|
-
var CompositeTypes = {
|
|
35
|
-
ImpureClass: 0,
|
|
36
|
-
PureClass: 1,
|
|
37
|
-
StatelessFunctional: 2
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
function StatelessComponent(Component) {}
|
|
41
|
-
StatelessComponent.prototype.render = function () {
|
|
42
|
-
var Component = ReactInstanceMap.get(this)._currentElement.type;
|
|
43
|
-
var element = Component(this.props, this.context, this.updater);
|
|
44
|
-
warnIfInvalidElement(Component, element);
|
|
45
|
-
return element;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
function warnIfInvalidElement(Component, element) {
|
|
49
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
50
|
-
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') : void 0;
|
|
51
|
-
process.env.NODE_ENV !== 'production' ? warning(!Component.childContextTypes, '%s(...): childContextTypes cannot be defined on a functional component.', Component.displayName || Component.name || 'Component') : void 0;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function shouldConstruct(Component) {
|
|
56
|
-
return !!(Component.prototype && Component.prototype.isReactComponent);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function isPureComponent(Component) {
|
|
60
|
-
return !!(Component.prototype && Component.prototype.isPureReactComponent);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Separated into a function to contain deoptimizations caused by try/finally.
|
|
64
|
-
function measureLifeCyclePerf(fn, debugID, timerType) {
|
|
65
|
-
if (debugID === 0) {
|
|
66
|
-
// Top-level wrappers (see ReactMount) and empty components (see
|
|
67
|
-
// ReactDOMEmptyComponent) are invisible to hooks and devtools.
|
|
68
|
-
// Both are implementation details that should go away in the future.
|
|
69
|
-
return fn();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
ReactInstrumentation.debugTool.onBeginLifeCycleTimer(debugID, timerType);
|
|
73
|
-
try {
|
|
74
|
-
return fn();
|
|
75
|
-
} finally {
|
|
76
|
-
ReactInstrumentation.debugTool.onEndLifeCycleTimer(debugID, timerType);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* ------------------ The Life-Cycle of a Composite Component ------------------
|
|
82
|
-
*
|
|
83
|
-
* - constructor: Initialization of state. The instance is now retained.
|
|
84
|
-
* - componentWillMount
|
|
85
|
-
* - render
|
|
86
|
-
* - [children's constructors]
|
|
87
|
-
* - [children's componentWillMount and render]
|
|
88
|
-
* - [children's componentDidMount]
|
|
89
|
-
* - componentDidMount
|
|
90
|
-
*
|
|
91
|
-
* Update Phases:
|
|
92
|
-
* - componentWillReceiveProps (only called if parent updated)
|
|
93
|
-
* - shouldComponentUpdate
|
|
94
|
-
* - componentWillUpdate
|
|
95
|
-
* - render
|
|
96
|
-
* - [children's constructors or receive props phases]
|
|
97
|
-
* - componentDidUpdate
|
|
98
|
-
*
|
|
99
|
-
* - componentWillUnmount
|
|
100
|
-
* - [children's componentWillUnmount]
|
|
101
|
-
* - [children destroyed]
|
|
102
|
-
* - (destroyed): The instance is now blank, released by React and ready for GC.
|
|
103
|
-
*
|
|
104
|
-
* -----------------------------------------------------------------------------
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* An incrementing ID assigned to each component when it is mounted. This is
|
|
109
|
-
* used to enforce the order in which `ReactUpdates` updates dirty components.
|
|
110
|
-
*
|
|
111
|
-
* @private
|
|
112
|
-
*/
|
|
113
|
-
var nextMountID = 1;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @lends {ReactCompositeComponent.prototype}
|
|
117
|
-
*/
|
|
118
|
-
var ReactCompositeComponentMixin = {
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Base constructor for all composite component.
|
|
122
|
-
*
|
|
123
|
-
* @param {ReactElement} element
|
|
124
|
-
* @final
|
|
125
|
-
* @internal
|
|
126
|
-
*/
|
|
127
|
-
construct: function (element) {
|
|
128
|
-
this._currentElement = element;
|
|
129
|
-
this._rootNodeID = 0;
|
|
130
|
-
this._compositeType = null;
|
|
131
|
-
this._instance = null;
|
|
132
|
-
this._hostParent = null;
|
|
133
|
-
this._hostContainerInfo = null;
|
|
134
|
-
|
|
135
|
-
// See ReactUpdateQueue
|
|
136
|
-
this._updateBatchNumber = null;
|
|
137
|
-
this._pendingElement = null;
|
|
138
|
-
this._pendingStateQueue = null;
|
|
139
|
-
this._pendingReplaceState = false;
|
|
140
|
-
this._pendingForceUpdate = false;
|
|
141
|
-
|
|
142
|
-
this._renderedNodeType = null;
|
|
143
|
-
this._renderedComponent = null;
|
|
144
|
-
this._context = null;
|
|
145
|
-
this._mountOrder = 0;
|
|
146
|
-
this._topLevelWrapper = null;
|
|
147
|
-
|
|
148
|
-
// See ReactUpdates and ReactUpdateQueue.
|
|
149
|
-
this._pendingCallbacks = null;
|
|
150
|
-
|
|
151
|
-
// ComponentWillUnmount shall only be called once
|
|
152
|
-
this._calledComponentWillUnmount = false;
|
|
153
|
-
|
|
154
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
155
|
-
this._warnedAboutRefsInRender = false;
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Initializes the component, renders markup, and registers event listeners.
|
|
161
|
-
*
|
|
162
|
-
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
163
|
-
* @param {?object} hostParent
|
|
164
|
-
* @param {?object} hostContainerInfo
|
|
165
|
-
* @param {?object} context
|
|
166
|
-
* @return {?string} Rendered markup to be inserted into the DOM.
|
|
167
|
-
* @final
|
|
168
|
-
* @internal
|
|
169
|
-
*/
|
|
170
|
-
mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
|
|
171
|
-
var _this = this;
|
|
172
|
-
|
|
173
|
-
this._context = context;
|
|
174
|
-
this._mountOrder = nextMountID++;
|
|
175
|
-
this._hostParent = hostParent;
|
|
176
|
-
this._hostContainerInfo = hostContainerInfo;
|
|
177
|
-
|
|
178
|
-
var publicProps = this._currentElement.props;
|
|
179
|
-
var publicContext = this._processContext(context);
|
|
180
|
-
|
|
181
|
-
var Component = this._currentElement.type;
|
|
182
|
-
|
|
183
|
-
var updateQueue = transaction.getUpdateQueue();
|
|
184
|
-
|
|
185
|
-
// Initialize the public class
|
|
186
|
-
var doConstruct = shouldConstruct(Component);
|
|
187
|
-
var inst = this._constructComponent(doConstruct, publicProps, publicContext, updateQueue);
|
|
188
|
-
var renderedElement;
|
|
189
|
-
|
|
190
|
-
// Support functional components
|
|
191
|
-
if (!doConstruct && (inst == null || inst.render == null)) {
|
|
192
|
-
renderedElement = inst;
|
|
193
|
-
warnIfInvalidElement(Component, renderedElement);
|
|
194
|
-
!(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') : _prodInvariant('105', Component.displayName || Component.name || 'Component') : void 0;
|
|
195
|
-
inst = new StatelessComponent(Component);
|
|
196
|
-
this._compositeType = CompositeTypes.StatelessFunctional;
|
|
197
|
-
} else {
|
|
198
|
-
if (isPureComponent(Component)) {
|
|
199
|
-
this._compositeType = CompositeTypes.PureClass;
|
|
200
|
-
} else {
|
|
201
|
-
this._compositeType = CompositeTypes.ImpureClass;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
206
|
-
// This will throw later in _renderValidatedComponent, but add an early
|
|
207
|
-
// warning now to help debugging
|
|
208
|
-
if (inst.render == null) {
|
|
209
|
-
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') : void 0;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
var propsMutated = inst.props !== publicProps;
|
|
213
|
-
var componentName = Component.displayName || Component.name || 'Component';
|
|
214
|
-
|
|
215
|
-
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) : void 0;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// These should be set up in the constructor, but as a convenience for
|
|
219
|
-
// simpler class abstractions, we set them up after the fact.
|
|
220
|
-
inst.props = publicProps;
|
|
221
|
-
inst.context = publicContext;
|
|
222
|
-
inst.refs = emptyObject;
|
|
223
|
-
inst.updater = updateQueue;
|
|
224
|
-
|
|
225
|
-
this._instance = inst;
|
|
226
|
-
|
|
227
|
-
// Store a reference from the instance back to the internal representation
|
|
228
|
-
ReactInstanceMap.set(inst, this);
|
|
229
|
-
|
|
230
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
231
|
-
// Since plain JS classes are defined without any special initialization
|
|
232
|
-
// logic, we can not catch common errors early. Therefore, we have to
|
|
233
|
-
// catch them here, at initialization time, instead.
|
|
234
|
-
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') : void 0;
|
|
235
|
-
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') : void 0;
|
|
236
|
-
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') : void 0;
|
|
237
|
-
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') : void 0;
|
|
238
|
-
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') : void 0;
|
|
239
|
-
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') : void 0;
|
|
240
|
-
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : void 0;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
var initialState = inst.state;
|
|
244
|
-
if (initialState === undefined) {
|
|
245
|
-
inst.state = initialState = null;
|
|
246
|
-
}
|
|
247
|
-
!(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') : _prodInvariant('106', this.getName() || 'ReactCompositeComponent') : void 0;
|
|
248
|
-
|
|
249
|
-
this._pendingStateQueue = null;
|
|
250
|
-
this._pendingReplaceState = false;
|
|
251
|
-
this._pendingForceUpdate = false;
|
|
252
|
-
|
|
253
|
-
var markup;
|
|
254
|
-
if (inst.unstable_handleError) {
|
|
255
|
-
markup = this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
|
256
|
-
} else {
|
|
257
|
-
markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (inst.componentDidMount) {
|
|
261
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
262
|
-
transaction.getReactMountReady().enqueue(function () {
|
|
263
|
-
measureLifeCyclePerf(function () {
|
|
264
|
-
return inst.componentDidMount();
|
|
265
|
-
}, _this._debugID, 'componentDidMount');
|
|
266
|
-
});
|
|
267
|
-
} else {
|
|
268
|
-
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return markup;
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
_constructComponent: function (doConstruct, publicProps, publicContext, updateQueue) {
|
|
276
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
277
|
-
ReactCurrentOwner.current = this;
|
|
278
|
-
try {
|
|
279
|
-
return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue);
|
|
280
|
-
} finally {
|
|
281
|
-
ReactCurrentOwner.current = null;
|
|
282
|
-
}
|
|
283
|
-
} else {
|
|
284
|
-
return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue);
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
_constructComponentWithoutOwner: function (doConstruct, publicProps, publicContext, updateQueue) {
|
|
289
|
-
var Component = this._currentElement.type;
|
|
290
|
-
|
|
291
|
-
if (doConstruct) {
|
|
292
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
293
|
-
return measureLifeCyclePerf(function () {
|
|
294
|
-
return new Component(publicProps, publicContext, updateQueue);
|
|
295
|
-
}, this._debugID, 'ctor');
|
|
296
|
-
} else {
|
|
297
|
-
return new Component(publicProps, publicContext, updateQueue);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// This can still be an instance in case of factory components
|
|
302
|
-
// but we'll count this as time spent rendering as the more common case.
|
|
303
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
304
|
-
return measureLifeCyclePerf(function () {
|
|
305
|
-
return Component(publicProps, publicContext, updateQueue);
|
|
306
|
-
}, this._debugID, 'render');
|
|
307
|
-
} else {
|
|
308
|
-
return Component(publicProps, publicContext, updateQueue);
|
|
309
|
-
}
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
performInitialMountWithErrorHandling: function (renderedElement, hostParent, hostContainerInfo, transaction, context) {
|
|
313
|
-
var markup;
|
|
314
|
-
var checkpoint = transaction.checkpoint();
|
|
315
|
-
try {
|
|
316
|
-
markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
|
317
|
-
} catch (e) {
|
|
318
|
-
// Roll back to checkpoint, handle error (which may add items to the transaction), and take a new checkpoint
|
|
319
|
-
transaction.rollback(checkpoint);
|
|
320
|
-
this._instance.unstable_handleError(e);
|
|
321
|
-
if (this._pendingStateQueue) {
|
|
322
|
-
this._instance.state = this._processPendingState(this._instance.props, this._instance.context);
|
|
323
|
-
}
|
|
324
|
-
checkpoint = transaction.checkpoint();
|
|
325
|
-
|
|
326
|
-
this._renderedComponent.unmountComponent(true);
|
|
327
|
-
transaction.rollback(checkpoint);
|
|
328
|
-
|
|
329
|
-
// Try again - we've informed the component about the error, so they can render an error message this time.
|
|
330
|
-
// If this throws again, the error will bubble up (and can be caught by a higher error boundary).
|
|
331
|
-
markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
|
332
|
-
}
|
|
333
|
-
return markup;
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
performInitialMount: function (renderedElement, hostParent, hostContainerInfo, transaction, context) {
|
|
337
|
-
var inst = this._instance;
|
|
338
|
-
|
|
339
|
-
var debugID = 0;
|
|
340
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
341
|
-
debugID = this._debugID;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (inst.componentWillMount) {
|
|
345
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
346
|
-
measureLifeCyclePerf(function () {
|
|
347
|
-
return inst.componentWillMount();
|
|
348
|
-
}, debugID, 'componentWillMount');
|
|
349
|
-
} else {
|
|
350
|
-
inst.componentWillMount();
|
|
351
|
-
}
|
|
352
|
-
// When mounting, calls to `setState` by `componentWillMount` will set
|
|
353
|
-
// `this._pendingStateQueue` without triggering a re-render.
|
|
354
|
-
if (this._pendingStateQueue) {
|
|
355
|
-
inst.state = this._processPendingState(inst.props, inst.context);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// If not a stateless component, we now render
|
|
360
|
-
if (renderedElement === undefined) {
|
|
361
|
-
renderedElement = this._renderValidatedComponent();
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
var nodeType = ReactNodeTypes.getType(renderedElement);
|
|
365
|
-
this._renderedNodeType = nodeType;
|
|
366
|
-
var child = this._instantiateReactComponent(renderedElement, nodeType !== ReactNodeTypes.EMPTY /* shouldHaveDebugID */
|
|
367
|
-
);
|
|
368
|
-
this._renderedComponent = child;
|
|
369
|
-
|
|
370
|
-
var markup = ReactReconciler.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context), debugID);
|
|
371
|
-
|
|
372
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
373
|
-
if (debugID !== 0) {
|
|
374
|
-
var childDebugIDs = child._debugID !== 0 ? [child._debugID] : [];
|
|
375
|
-
ReactInstrumentation.debugTool.onSetChildren(debugID, childDebugIDs);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
return markup;
|
|
380
|
-
},
|
|
381
|
-
|
|
382
|
-
getHostNode: function () {
|
|
383
|
-
return ReactReconciler.getHostNode(this._renderedComponent);
|
|
384
|
-
},
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Releases any resources allocated by `mountComponent`.
|
|
388
|
-
*
|
|
389
|
-
* @final
|
|
390
|
-
* @internal
|
|
391
|
-
*/
|
|
392
|
-
unmountComponent: function (safely) {
|
|
393
|
-
if (!this._renderedComponent) {
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
var inst = this._instance;
|
|
398
|
-
|
|
399
|
-
if (inst.componentWillUnmount && !inst._calledComponentWillUnmount) {
|
|
400
|
-
inst._calledComponentWillUnmount = true;
|
|
401
|
-
|
|
402
|
-
if (safely) {
|
|
403
|
-
var name = this.getName() + '.componentWillUnmount()';
|
|
404
|
-
ReactErrorUtils.invokeGuardedCallback(name, inst.componentWillUnmount.bind(inst));
|
|
405
|
-
} else {
|
|
406
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
407
|
-
measureLifeCyclePerf(function () {
|
|
408
|
-
return inst.componentWillUnmount();
|
|
409
|
-
}, this._debugID, 'componentWillUnmount');
|
|
410
|
-
} else {
|
|
411
|
-
inst.componentWillUnmount();
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
if (this._renderedComponent) {
|
|
417
|
-
ReactReconciler.unmountComponent(this._renderedComponent, safely);
|
|
418
|
-
this._renderedNodeType = null;
|
|
419
|
-
this._renderedComponent = null;
|
|
420
|
-
this._instance = null;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
// Reset pending fields
|
|
424
|
-
// Even if this component is scheduled for another update in ReactUpdates,
|
|
425
|
-
// it would still be ignored because these fields are reset.
|
|
426
|
-
this._pendingStateQueue = null;
|
|
427
|
-
this._pendingReplaceState = false;
|
|
428
|
-
this._pendingForceUpdate = false;
|
|
429
|
-
this._pendingCallbacks = null;
|
|
430
|
-
this._pendingElement = null;
|
|
431
|
-
|
|
432
|
-
// These fields do not really need to be reset since this object is no
|
|
433
|
-
// longer accessible.
|
|
434
|
-
this._context = null;
|
|
435
|
-
this._rootNodeID = 0;
|
|
436
|
-
this._topLevelWrapper = null;
|
|
437
|
-
|
|
438
|
-
// Delete the reference from the instance to this internal representation
|
|
439
|
-
// which allow the internals to be properly cleaned up even if the user
|
|
440
|
-
// leaks a reference to the public instance.
|
|
441
|
-
ReactInstanceMap.remove(inst);
|
|
442
|
-
|
|
443
|
-
// Some existing components rely on inst.props even after they've been
|
|
444
|
-
// destroyed (in event handlers).
|
|
445
|
-
// TODO: inst.props = null;
|
|
446
|
-
// TODO: inst.state = null;
|
|
447
|
-
// TODO: inst.context = null;
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Filters the context object to only contain keys specified in
|
|
452
|
-
* `contextTypes`
|
|
453
|
-
*
|
|
454
|
-
* @param {object} context
|
|
455
|
-
* @return {?object}
|
|
456
|
-
* @private
|
|
457
|
-
*/
|
|
458
|
-
_maskContext: function (context) {
|
|
459
|
-
var Component = this._currentElement.type;
|
|
460
|
-
var contextTypes = Component.contextTypes;
|
|
461
|
-
if (!contextTypes) {
|
|
462
|
-
return emptyObject;
|
|
463
|
-
}
|
|
464
|
-
var maskedContext = {};
|
|
465
|
-
for (var contextName in contextTypes) {
|
|
466
|
-
maskedContext[contextName] = context[contextName];
|
|
467
|
-
}
|
|
468
|
-
return maskedContext;
|
|
469
|
-
},
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Filters the context object to only contain keys specified in
|
|
473
|
-
* `contextTypes`, and asserts that they are valid.
|
|
474
|
-
*
|
|
475
|
-
* @param {object} context
|
|
476
|
-
* @return {?object}
|
|
477
|
-
* @private
|
|
478
|
-
*/
|
|
479
|
-
_processContext: function (context) {
|
|
480
|
-
var maskedContext = this._maskContext(context);
|
|
481
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
482
|
-
var Component = this._currentElement.type;
|
|
483
|
-
if (Component.contextTypes) {
|
|
484
|
-
this._checkContextTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return maskedContext;
|
|
488
|
-
},
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* @param {object} currentContext
|
|
492
|
-
* @return {object}
|
|
493
|
-
* @private
|
|
494
|
-
*/
|
|
495
|
-
_processChildContext: function (currentContext) {
|
|
496
|
-
var Component = this._currentElement.type;
|
|
497
|
-
var inst = this._instance;
|
|
498
|
-
var childContext;
|
|
499
|
-
|
|
500
|
-
if (inst.getChildContext) {
|
|
501
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
502
|
-
ReactInstrumentation.debugTool.onBeginProcessingChildContext();
|
|
503
|
-
try {
|
|
504
|
-
childContext = inst.getChildContext();
|
|
505
|
-
} finally {
|
|
506
|
-
ReactInstrumentation.debugTool.onEndProcessingChildContext();
|
|
507
|
-
}
|
|
508
|
-
} else {
|
|
509
|
-
childContext = inst.getChildContext();
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
if (childContext) {
|
|
514
|
-
!(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') : _prodInvariant('107', this.getName() || 'ReactCompositeComponent') : void 0;
|
|
515
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
516
|
-
this._checkContextTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
|
|
517
|
-
}
|
|
518
|
-
for (var name in childContext) {
|
|
519
|
-
!(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : _prodInvariant('108', this.getName() || 'ReactCompositeComponent', name) : void 0;
|
|
520
|
-
}
|
|
521
|
-
return _assign({}, currentContext, childContext);
|
|
522
|
-
}
|
|
523
|
-
return currentContext;
|
|
524
|
-
},
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* Assert that the context types are valid
|
|
528
|
-
*
|
|
529
|
-
* @param {object} typeSpecs Map of context field to a ReactPropType
|
|
530
|
-
* @param {object} values Runtime values that need to be type-checked
|
|
531
|
-
* @param {string} location e.g. "prop", "context", "child context"
|
|
532
|
-
* @private
|
|
533
|
-
*/
|
|
534
|
-
_checkContextTypes: function (typeSpecs, values, location) {
|
|
535
|
-
checkReactTypeSpec(typeSpecs, values, location, this.getName(), null, this._debugID);
|
|
536
|
-
},
|
|
537
|
-
|
|
538
|
-
receiveComponent: function (nextElement, transaction, nextContext) {
|
|
539
|
-
var prevElement = this._currentElement;
|
|
540
|
-
var prevContext = this._context;
|
|
541
|
-
|
|
542
|
-
this._pendingElement = null;
|
|
543
|
-
|
|
544
|
-
this.updateComponent(transaction, prevElement, nextElement, prevContext, nextContext);
|
|
545
|
-
},
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate`
|
|
549
|
-
* is set, update the component.
|
|
550
|
-
*
|
|
551
|
-
* @param {ReactReconcileTransaction} transaction
|
|
552
|
-
* @internal
|
|
553
|
-
*/
|
|
554
|
-
performUpdateIfNecessary: function (transaction) {
|
|
555
|
-
if (this._pendingElement != null) {
|
|
556
|
-
ReactReconciler.receiveComponent(this, this._pendingElement, transaction, this._context);
|
|
557
|
-
} else if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
|
|
558
|
-
this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context);
|
|
559
|
-
} else {
|
|
560
|
-
this._updateBatchNumber = null;
|
|
561
|
-
}
|
|
562
|
-
},
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Perform an update to a mounted component. The componentWillReceiveProps and
|
|
566
|
-
* shouldComponentUpdate methods are called, then (assuming the update isn't
|
|
567
|
-
* skipped) the remaining update lifecycle methods are called and the DOM
|
|
568
|
-
* representation is updated.
|
|
569
|
-
*
|
|
570
|
-
* By default, this implements React's rendering and reconciliation algorithm.
|
|
571
|
-
* Sophisticated clients may wish to override this.
|
|
572
|
-
*
|
|
573
|
-
* @param {ReactReconcileTransaction} transaction
|
|
574
|
-
* @param {ReactElement} prevParentElement
|
|
575
|
-
* @param {ReactElement} nextParentElement
|
|
576
|
-
* @internal
|
|
577
|
-
* @overridable
|
|
578
|
-
*/
|
|
579
|
-
updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
|
|
580
|
-
var inst = this._instance;
|
|
581
|
-
!(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Attempted to update component `%s` that has already been unmounted (or failed to mount).', this.getName() || 'ReactCompositeComponent') : _prodInvariant('136', this.getName() || 'ReactCompositeComponent') : void 0;
|
|
582
|
-
|
|
583
|
-
var willReceive = false;
|
|
584
|
-
var nextContext;
|
|
585
|
-
|
|
586
|
-
// Determine if the context has changed or not
|
|
587
|
-
if (this._context === nextUnmaskedContext) {
|
|
588
|
-
nextContext = inst.context;
|
|
589
|
-
} else {
|
|
590
|
-
nextContext = this._processContext(nextUnmaskedContext);
|
|
591
|
-
willReceive = true;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
var prevProps = prevParentElement.props;
|
|
595
|
-
var nextProps = nextParentElement.props;
|
|
596
|
-
|
|
597
|
-
// Not a simple state update but a props update
|
|
598
|
-
if (prevParentElement !== nextParentElement) {
|
|
599
|
-
willReceive = true;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// An update here will schedule an update but immediately set
|
|
603
|
-
// _pendingStateQueue which will ensure that any state updates gets
|
|
604
|
-
// immediately reconciled instead of waiting for the next batch.
|
|
605
|
-
if (willReceive && inst.componentWillReceiveProps) {
|
|
606
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
607
|
-
measureLifeCyclePerf(function () {
|
|
608
|
-
return inst.componentWillReceiveProps(nextProps, nextContext);
|
|
609
|
-
}, this._debugID, 'componentWillReceiveProps');
|
|
610
|
-
} else {
|
|
611
|
-
inst.componentWillReceiveProps(nextProps, nextContext);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
var nextState = this._processPendingState(nextProps, nextContext);
|
|
616
|
-
var shouldUpdate = true;
|
|
617
|
-
|
|
618
|
-
if (!this._pendingForceUpdate) {
|
|
619
|
-
if (inst.shouldComponentUpdate) {
|
|
620
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
621
|
-
shouldUpdate = measureLifeCyclePerf(function () {
|
|
622
|
-
return inst.shouldComponentUpdate(nextProps, nextState, nextContext);
|
|
623
|
-
}, this._debugID, 'shouldComponentUpdate');
|
|
624
|
-
} else {
|
|
625
|
-
shouldUpdate = inst.shouldComponentUpdate(nextProps, nextState, nextContext);
|
|
626
|
-
}
|
|
627
|
-
} else {
|
|
628
|
-
if (this._compositeType === CompositeTypes.PureClass) {
|
|
629
|
-
shouldUpdate = !shallowEqual(prevProps, nextProps) || !shallowEqual(inst.state, nextState);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
635
|
-
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') : void 0;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
this._updateBatchNumber = null;
|
|
639
|
-
if (shouldUpdate) {
|
|
640
|
-
this._pendingForceUpdate = false;
|
|
641
|
-
// Will set `this.props`, `this.state` and `this.context`.
|
|
642
|
-
this._performComponentUpdate(nextParentElement, nextProps, nextState, nextContext, transaction, nextUnmaskedContext);
|
|
643
|
-
} else {
|
|
644
|
-
// If it's determined that a component should not update, we still want
|
|
645
|
-
// to set props and state but we shortcut the rest of the update.
|
|
646
|
-
this._currentElement = nextParentElement;
|
|
647
|
-
this._context = nextUnmaskedContext;
|
|
648
|
-
inst.props = nextProps;
|
|
649
|
-
inst.state = nextState;
|
|
650
|
-
inst.context = nextContext;
|
|
651
|
-
}
|
|
652
|
-
},
|
|
653
|
-
|
|
654
|
-
_processPendingState: function (props, context) {
|
|
655
|
-
var inst = this._instance;
|
|
656
|
-
var queue = this._pendingStateQueue;
|
|
657
|
-
var replace = this._pendingReplaceState;
|
|
658
|
-
this._pendingReplaceState = false;
|
|
659
|
-
this._pendingStateQueue = null;
|
|
660
|
-
|
|
661
|
-
if (!queue) {
|
|
662
|
-
return inst.state;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
if (replace && queue.length === 1) {
|
|
666
|
-
return queue[0];
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
var nextState = _assign({}, replace ? queue[0] : inst.state);
|
|
670
|
-
for (var i = replace ? 1 : 0; i < queue.length; i++) {
|
|
671
|
-
var partial = queue[i];
|
|
672
|
-
_assign(nextState, typeof partial === 'function' ? partial.call(inst, nextState, props, context) : partial);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
return nextState;
|
|
676
|
-
},
|
|
677
|
-
|
|
678
|
-
/**
|
|
679
|
-
* Merges new props and state, notifies delegate methods of update and
|
|
680
|
-
* performs update.
|
|
681
|
-
*
|
|
682
|
-
* @param {ReactElement} nextElement Next element
|
|
683
|
-
* @param {object} nextProps Next public object to set as properties.
|
|
684
|
-
* @param {?object} nextState Next object to set as state.
|
|
685
|
-
* @param {?object} nextContext Next public object to set as context.
|
|
686
|
-
* @param {ReactReconcileTransaction} transaction
|
|
687
|
-
* @param {?object} unmaskedContext
|
|
688
|
-
* @private
|
|
689
|
-
*/
|
|
690
|
-
_performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) {
|
|
691
|
-
var _this2 = this;
|
|
692
|
-
|
|
693
|
-
var inst = this._instance;
|
|
694
|
-
|
|
695
|
-
var hasComponentDidUpdate = Boolean(inst.componentDidUpdate);
|
|
696
|
-
var prevProps;
|
|
697
|
-
var prevState;
|
|
698
|
-
var prevContext;
|
|
699
|
-
if (hasComponentDidUpdate) {
|
|
700
|
-
prevProps = inst.props;
|
|
701
|
-
prevState = inst.state;
|
|
702
|
-
prevContext = inst.context;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
if (inst.componentWillUpdate) {
|
|
706
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
707
|
-
measureLifeCyclePerf(function () {
|
|
708
|
-
return inst.componentWillUpdate(nextProps, nextState, nextContext);
|
|
709
|
-
}, this._debugID, 'componentWillUpdate');
|
|
710
|
-
} else {
|
|
711
|
-
inst.componentWillUpdate(nextProps, nextState, nextContext);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
this._currentElement = nextElement;
|
|
716
|
-
this._context = unmaskedContext;
|
|
717
|
-
inst.props = nextProps;
|
|
718
|
-
inst.state = nextState;
|
|
719
|
-
inst.context = nextContext;
|
|
720
|
-
|
|
721
|
-
this._updateRenderedComponent(transaction, unmaskedContext);
|
|
722
|
-
|
|
723
|
-
if (hasComponentDidUpdate) {
|
|
724
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
725
|
-
transaction.getReactMountReady().enqueue(function () {
|
|
726
|
-
measureLifeCyclePerf(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), _this2._debugID, 'componentDidUpdate');
|
|
727
|
-
});
|
|
728
|
-
} else {
|
|
729
|
-
transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
},
|
|
733
|
-
|
|
734
|
-
/**
|
|
735
|
-
* Call the component's `render` method and update the DOM accordingly.
|
|
736
|
-
*
|
|
737
|
-
* @param {ReactReconcileTransaction} transaction
|
|
738
|
-
* @internal
|
|
739
|
-
*/
|
|
740
|
-
_updateRenderedComponent: function (transaction, context) {
|
|
741
|
-
var prevComponentInstance = this._renderedComponent;
|
|
742
|
-
var prevRenderedElement = prevComponentInstance._currentElement;
|
|
743
|
-
var nextRenderedElement = this._renderValidatedComponent();
|
|
744
|
-
|
|
745
|
-
var debugID = 0;
|
|
746
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
747
|
-
debugID = this._debugID;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
|
|
751
|
-
ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
|
|
752
|
-
} else {
|
|
753
|
-
var oldHostNode = ReactReconciler.getHostNode(prevComponentInstance);
|
|
754
|
-
ReactReconciler.unmountComponent(prevComponentInstance, false);
|
|
755
|
-
|
|
756
|
-
var nodeType = ReactNodeTypes.getType(nextRenderedElement);
|
|
757
|
-
this._renderedNodeType = nodeType;
|
|
758
|
-
var child = this._instantiateReactComponent(nextRenderedElement, nodeType !== ReactNodeTypes.EMPTY /* shouldHaveDebugID */
|
|
759
|
-
);
|
|
760
|
-
this._renderedComponent = child;
|
|
761
|
-
|
|
762
|
-
var nextMarkup = ReactReconciler.mountComponent(child, transaction, this._hostParent, this._hostContainerInfo, this._processChildContext(context), debugID);
|
|
763
|
-
|
|
764
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
765
|
-
if (debugID !== 0) {
|
|
766
|
-
var childDebugIDs = child._debugID !== 0 ? [child._debugID] : [];
|
|
767
|
-
ReactInstrumentation.debugTool.onSetChildren(debugID, childDebugIDs);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
this._replaceNodeWithMarkup(oldHostNode, nextMarkup, prevComponentInstance);
|
|
772
|
-
}
|
|
773
|
-
},
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* Overridden in shallow rendering.
|
|
777
|
-
*
|
|
778
|
-
* @protected
|
|
779
|
-
*/
|
|
780
|
-
_replaceNodeWithMarkup: function (oldHostNode, nextMarkup, prevInstance) {
|
|
781
|
-
ReactComponentEnvironment.replaceNodeWithMarkup(oldHostNode, nextMarkup, prevInstance);
|
|
782
|
-
},
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* @protected
|
|
786
|
-
*/
|
|
787
|
-
_renderValidatedComponentWithoutOwnerOrContext: function () {
|
|
788
|
-
var inst = this._instance;
|
|
789
|
-
var renderedComponent;
|
|
790
|
-
|
|
791
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
792
|
-
renderedComponent = measureLifeCyclePerf(function () {
|
|
793
|
-
return inst.render();
|
|
794
|
-
}, this._debugID, 'render');
|
|
795
|
-
} else {
|
|
796
|
-
renderedComponent = inst.render();
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
800
|
-
// We allow auto-mocks to proceed as if they're returning null.
|
|
801
|
-
if (renderedComponent === undefined && inst.render._isMockFunction) {
|
|
802
|
-
// This is probably bad practice. Consider warning here and
|
|
803
|
-
// deprecating this convenience.
|
|
804
|
-
renderedComponent = null;
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
return renderedComponent;
|
|
809
|
-
},
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* @private
|
|
813
|
-
*/
|
|
814
|
-
_renderValidatedComponent: function () {
|
|
815
|
-
var renderedComponent;
|
|
816
|
-
if (process.env.NODE_ENV !== 'production' || this._compositeType !== CompositeTypes.StatelessFunctional) {
|
|
817
|
-
ReactCurrentOwner.current = this;
|
|
818
|
-
try {
|
|
819
|
-
renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext();
|
|
820
|
-
} finally {
|
|
821
|
-
ReactCurrentOwner.current = null;
|
|
822
|
-
}
|
|
823
|
-
} else {
|
|
824
|
-
renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext();
|
|
825
|
-
}
|
|
826
|
-
!(
|
|
827
|
-
// TODO: An `isValidNode` function would probably be more appropriate
|
|
828
|
-
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') : _prodInvariant('109', this.getName() || 'ReactCompositeComponent') : void 0;
|
|
829
|
-
|
|
830
|
-
return renderedComponent;
|
|
831
|
-
},
|
|
832
|
-
|
|
833
|
-
/**
|
|
834
|
-
* Lazily allocates the refs object and stores `component` as `ref`.
|
|
835
|
-
*
|
|
836
|
-
* @param {string} ref Reference name.
|
|
837
|
-
* @param {component} component Component to store as `ref`.
|
|
838
|
-
* @final
|
|
839
|
-
* @private
|
|
840
|
-
*/
|
|
841
|
-
attachRef: function (ref, component) {
|
|
842
|
-
var inst = this.getPublicInstance();
|
|
843
|
-
!(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : _prodInvariant('110') : void 0;
|
|
844
|
-
var publicComponentInstance = component.getPublicInstance();
|
|
845
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
846
|
-
var componentName = component && component.getName ? component.getName() : 'a component';
|
|
847
|
-
process.env.NODE_ENV !== 'production' ? warning(publicComponentInstance != null || component._compositeType !== CompositeTypes.StatelessFunctional, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', ref, componentName, this.getName()) : void 0;
|
|
848
|
-
}
|
|
849
|
-
var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs;
|
|
850
|
-
refs[ref] = publicComponentInstance;
|
|
851
|
-
},
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Detaches a reference name.
|
|
855
|
-
*
|
|
856
|
-
* @param {string} ref Name to dereference.
|
|
857
|
-
* @final
|
|
858
|
-
* @private
|
|
859
|
-
*/
|
|
860
|
-
detachRef: function (ref) {
|
|
861
|
-
var refs = this.getPublicInstance().refs;
|
|
862
|
-
delete refs[ref];
|
|
863
|
-
},
|
|
864
|
-
|
|
865
|
-
/**
|
|
866
|
-
* Get a text description of the component that can be used to identify it
|
|
867
|
-
* in error messages.
|
|
868
|
-
* @return {string} The name or null.
|
|
869
|
-
* @internal
|
|
870
|
-
*/
|
|
871
|
-
getName: function () {
|
|
872
|
-
var type = this._currentElement.type;
|
|
873
|
-
var constructor = this._instance && this._instance.constructor;
|
|
874
|
-
return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null;
|
|
875
|
-
},
|
|
876
|
-
|
|
877
|
-
/**
|
|
878
|
-
* Get the publicly accessible representation of this component - i.e. what
|
|
879
|
-
* is exposed by refs and returned by render. Can be null for stateless
|
|
880
|
-
* components.
|
|
881
|
-
*
|
|
882
|
-
* @return {ReactComponent} the public component instance.
|
|
883
|
-
* @internal
|
|
884
|
-
*/
|
|
885
|
-
getPublicInstance: function () {
|
|
886
|
-
var inst = this._instance;
|
|
887
|
-
if (this._compositeType === CompositeTypes.StatelessFunctional) {
|
|
888
|
-
return null;
|
|
889
|
-
}
|
|
890
|
-
return inst;
|
|
891
|
-
},
|
|
892
|
-
|
|
893
|
-
// Stub
|
|
894
|
-
_instantiateReactComponent: null
|
|
895
|
-
|
|
896
|
-
};
|
|
897
|
-
|
|
898
|
-
var ReactCompositeComponent = {
|
|
899
|
-
|
|
900
|
-
Mixin: ReactCompositeComponentMixin
|
|
901
|
-
|
|
902
|
-
};
|
|
903
|
-
|
|
904
|
-
module.exports = ReactCompositeComponent;
|