react 15.1.0 → 15.2.1
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 +2685 -1842
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +2400 -1691
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/CallbackQueue.js +3 -2
- package/lib/DOMChildrenOperations.js +9 -9
- package/lib/DOMLazyTree.js +3 -2
- package/lib/DOMProperty.js +5 -12
- package/lib/DOMPropertyOperations.js +21 -15
- package/lib/Danger.js +5 -101
- package/lib/DisabledInputUtils.js +5 -5
- package/lib/EventPluginHub.js +8 -2
- package/lib/EventPluginRegistry.js +13 -7
- package/lib/EventPluginUtils.js +3 -1
- package/lib/HTMLDOMPropertyConfig.js +1 -2
- package/lib/KeyEscapeUtils.js +2 -1
- package/lib/LinkedValueUtils.js +5 -3
- package/lib/NativeMethodsMixin.js +6 -4
- package/lib/PooledClass.js +4 -2
- package/lib/React.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +15 -8
- package/lib/ReactChildReconciler.js +17 -8
- package/lib/ReactClass.js +14 -13
- package/lib/ReactComponent.js +3 -6
- package/lib/ReactComponentEnvironment.js +3 -1
- package/lib/ReactComponentTreeDevtool.js +89 -16
- package/lib/ReactComponentTreeTestUtils.js +87 -0
- package/lib/ReactCompositeComponent.js +87 -117
- package/lib/ReactDOM.js +2 -2
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +130 -76
- package/lib/ReactDOMComponentTree.js +23 -21
- package/lib/ReactDOMDebugTool.js +17 -11
- package/lib/ReactDOMEmptyComponent.js +9 -9
- package/lib/ReactDOMFactories.js +1 -1
- package/lib/ReactDOMFiber.js +78 -0
- package/lib/ReactDOMInput.js +64 -26
- package/lib/ReactDOMInstrumentation.js +7 -2
- package/lib/ReactDOMNullInputValuePropDevtool.js +43 -0
- package/lib/ReactDOMOption.js +40 -26
- package/lib/ReactDOMSelect.js +3 -16
- package/lib/ReactDOMTextComponent.js +21 -20
- package/lib/ReactDOMTextarea.js +59 -46
- package/lib/ReactDOMTreeTraversal.js +18 -16
- package/lib/ReactDOMUnknownPropertyDevtool.js +65 -17
- package/lib/ReactDebugTool.js +148 -95
- package/lib/ReactDefaultInjection.js +2 -2
- package/lib/ReactElement.js +64 -25
- package/lib/ReactElementValidator.js +26 -81
- package/lib/ReactEventListener.js +2 -2
- package/lib/ReactFeatureFlags.js +1 -0
- package/lib/ReactFragment.js +3 -1
- package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
- package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +5 -5
- package/lib/ReactInjection.js +2 -2
- package/lib/ReactInstanceHandles.js +8 -6
- package/lib/ReactInstrumentation.js +7 -2
- package/lib/ReactMount.js +38 -32
- package/lib/ReactMultiChild.js +38 -11
- package/lib/ReactNativeAttributePayload.js +5 -2
- package/lib/ReactNativeBaseComponent.js +7 -7
- package/lib/ReactNativeBridgeEventPlugin.js +1 -1
- package/lib/ReactNativeComponentTree.js +8 -6
- package/lib/ReactNativeDOMIDOperations.js +1 -2
- package/lib/ReactNativeDefaultInjection.js +9 -7
- package/lib/ReactNativeGlobalResponderHandler.js +1 -1
- package/lib/ReactNativeMount.js +3 -14
- package/lib/ReactNativeReconcileTransaction.js +16 -0
- package/lib/ReactNativeTagHandles.js +3 -1
- package/lib/ReactNativeTextComponent.js +10 -9
- package/lib/ReactNativeTreeTraversal.js +11 -11
- package/lib/ReactNodeTypes.js +6 -3
- package/lib/ReactNoop.js +173 -0
- package/lib/ReactNoopUpdateQueue.js +6 -5
- package/lib/ReactOwner.js +4 -2
- package/lib/ReactPerf.js +83 -7
- package/lib/ReactPropTypes.js +23 -0
- package/lib/ReactReconcileTransaction.js +17 -1
- package/lib/ReactReconciler.js +12 -7
- package/lib/ReactServerRendering.js +5 -7
- package/lib/ReactServerRenderingTransaction.js +17 -0
- package/lib/ReactServerUpdateQueue.js +141 -0
- package/lib/ReactSimpleEmptyComponent.js +4 -4
- package/lib/ReactTestMount.js +115 -0
- package/lib/ReactTestReconcileTransaction.js +108 -0
- package/lib/ReactTestRenderer.js +133 -0
- package/lib/ReactTestUtils.js +17 -10
- package/lib/ReactTransitionChildMapping.js +7 -1
- package/lib/ReactTransitionGroup.js +41 -6
- package/lib/ReactUpdateQueue.js +13 -3
- package/lib/ReactUpdates.js +10 -18
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +9 -7
- package/lib/ResponderTouchHistoryStore.js +99 -95
- package/lib/SimpleEventPlugin.js +3 -1
- package/lib/SyntheticEvent.js +2 -3
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/Transaction.js +4 -2
- package/lib/accumulate.js +17 -15
- package/lib/accumulateInto.js +11 -12
- package/lib/adler32.js +1 -0
- package/lib/checkReactTypeSpec.js +73 -0
- package/lib/createReactNativeComponentClass.js +2 -2
- package/lib/dangerousStyleValue.js +3 -1
- package/lib/deprecated.js +7 -1
- package/lib/escapeTextContentForBrowser.js +96 -12
- package/lib/findDOMNode.js +6 -4
- package/lib/findNodeHandle.js +5 -3
- package/lib/flattenChildren.js +22 -10
- package/lib/forEachAccumulated.js +3 -2
- package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
- package/lib/getIteratorFn.js +1 -0
- package/lib/instantiateReactComponent.js +21 -19
- package/lib/isTextInputElement.js +11 -1
- package/lib/onlyChild.js +3 -1
- package/lib/reactComponentExpect.js +3 -3
- package/lib/reactProdInvariant.js +39 -0
- package/lib/setInnerHTML.js +17 -1
- package/lib/setTextContent.js +8 -0
- package/lib/traverseAllChildren.js +3 -1
- package/lib/update.js +12 -11
- package/package.json +2 -2
- package/lib/MetaMatchers.js +0 -118
package/lib/ReactInjection.js
CHANGED
|
@@ -18,7 +18,7 @@ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
|
|
|
18
18
|
var ReactClass = require('./ReactClass');
|
|
19
19
|
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
20
20
|
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
21
|
-
var
|
|
21
|
+
var ReactHostComponent = require('./ReactHostComponent');
|
|
22
22
|
var ReactUpdates = require('./ReactUpdates');
|
|
23
23
|
|
|
24
24
|
var ReactInjection = {
|
|
@@ -29,7 +29,7 @@ var ReactInjection = {
|
|
|
29
29
|
EventPluginHub: EventPluginHub.injection,
|
|
30
30
|
EventPluginUtils: EventPluginUtils.injection,
|
|
31
31
|
EventEmitter: ReactBrowserEventEmitter.injection,
|
|
32
|
-
|
|
32
|
+
HostComponent: ReactHostComponent.injection,
|
|
33
33
|
Updates: ReactUpdates.injection
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var invariant = require('fbjs/lib/invariant');
|
|
15
17
|
|
|
16
18
|
var SEPARATOR = '.';
|
|
@@ -88,8 +90,8 @@ function getParentID(id) {
|
|
|
88
90
|
* @private
|
|
89
91
|
*/
|
|
90
92
|
function getNextDescendantID(ancestorID, destinationID) {
|
|
91
|
-
!(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) :
|
|
92
|
-
!isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about
|
|
93
|
+
!(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : _prodInvariant('112', ancestorID, destinationID) : void 0;
|
|
94
|
+
!isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : _prodInvariant('113', ancestorID, destinationID) : void 0;
|
|
93
95
|
if (ancestorID === destinationID) {
|
|
94
96
|
return ancestorID;
|
|
95
97
|
}
|
|
@@ -131,7 +133,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
135
|
var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
|
|
134
|
-
!isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) :
|
|
136
|
+
!isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : _prodInvariant('114', oneID, twoID, longestCommonID) : void 0;
|
|
135
137
|
return longestCommonID;
|
|
136
138
|
}
|
|
137
139
|
|
|
@@ -151,9 +153,9 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
151
153
|
function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
152
154
|
start = start || '';
|
|
153
155
|
stop = stop || '';
|
|
154
|
-
!(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) :
|
|
156
|
+
!(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : _prodInvariant('115', start) : void 0;
|
|
155
157
|
var traverseUp = isAncestorIDOf(stop, start);
|
|
156
|
-
!(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do
|
|
158
|
+
!(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do not have a parent path.', start, stop) : _prodInvariant('116', start, stop) : void 0;
|
|
157
159
|
// Traverse from `start` to `stop` one depth at a time.
|
|
158
160
|
var depth = 0;
|
|
159
161
|
var traverse = traverseUp ? getParentID : getNextDescendantID;
|
|
@@ -166,7 +168,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
|
166
168
|
// Only break //after// visiting `stop`.
|
|
167
169
|
break;
|
|
168
170
|
}
|
|
169
|
-
!(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while
|
|
171
|
+
!(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : _prodInvariant('117', start, stop, id) : void 0;
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var debugTool = null;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
17
|
+
var ReactDebugTool = require('./ReactDebugTool');
|
|
18
|
+
debugTool = ReactDebugTool;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = { debugTool: debugTool };
|
package/lib/ReactMount.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var DOMLazyTree = require('./DOMLazyTree');
|
|
15
17
|
var DOMProperty = require('./DOMProperty');
|
|
16
18
|
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
@@ -20,6 +22,7 @@ var ReactDOMContainerInfo = require('./ReactDOMContainerInfo');
|
|
|
20
22
|
var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
|
|
21
23
|
var ReactElement = require('./ReactElement');
|
|
22
24
|
var ReactFeatureFlags = require('./ReactFeatureFlags');
|
|
25
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
23
26
|
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
24
27
|
var ReactMarkupChecksum = require('./ReactMarkupChecksum');
|
|
25
28
|
var ReactReconciler = require('./ReactReconciler');
|
|
@@ -134,7 +137,13 @@ function batchedMountComponentIntoNode(componentInstance, container, shouldReuse
|
|
|
134
137
|
* @see {ReactMount.unmountComponentAtNode}
|
|
135
138
|
*/
|
|
136
139
|
function unmountComponentFromNode(instance, container, safely) {
|
|
140
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
141
|
+
ReactInstrumentation.debugTool.onBeginFlush();
|
|
142
|
+
}
|
|
137
143
|
ReactReconciler.unmountComponent(instance, safely);
|
|
144
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
145
|
+
ReactInstrumentation.debugTool.onEndFlush();
|
|
146
|
+
}
|
|
138
147
|
|
|
139
148
|
if (container.nodeType === DOC_NODE_TYPE) {
|
|
140
149
|
container = container.documentElement;
|
|
@@ -160,19 +169,19 @@ function hasNonRootReactChild(container) {
|
|
|
160
169
|
var rootEl = getReactRootElementInContainer(container);
|
|
161
170
|
if (rootEl) {
|
|
162
171
|
var inst = ReactDOMComponentTree.getInstanceFromNode(rootEl);
|
|
163
|
-
return !!(inst && inst.
|
|
172
|
+
return !!(inst && inst._hostParent);
|
|
164
173
|
}
|
|
165
174
|
}
|
|
166
175
|
|
|
167
|
-
function
|
|
176
|
+
function getHostRootInstanceInContainer(container) {
|
|
168
177
|
var rootEl = getReactRootElementInContainer(container);
|
|
169
|
-
var
|
|
170
|
-
return
|
|
178
|
+
var prevHostInstance = rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl);
|
|
179
|
+
return prevHostInstance && !prevHostInstance._hostParent ? prevHostInstance : null;
|
|
171
180
|
}
|
|
172
181
|
|
|
173
182
|
function getTopLevelWrapperInContainer(container) {
|
|
174
|
-
var root =
|
|
175
|
-
return root ? root.
|
|
183
|
+
var root = getHostRootInstanceInContainer(container);
|
|
184
|
+
return root ? root._hostContainerInfo._topLevelWrapper : null;
|
|
176
185
|
}
|
|
177
186
|
|
|
178
187
|
/**
|
|
@@ -239,9 +248,9 @@ var ReactMount = {
|
|
|
239
248
|
* @param {DOMElement} container container to render into
|
|
240
249
|
* @param {?function} callback function triggered on completion
|
|
241
250
|
*/
|
|
242
|
-
_updateRootComponent: function (prevComponent, nextElement, container, callback) {
|
|
251
|
+
_updateRootComponent: function (prevComponent, nextElement, nextContext, container, callback) {
|
|
243
252
|
ReactMount.scrollMonitor(container, function () {
|
|
244
|
-
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
|
|
253
|
+
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement, nextContext);
|
|
245
254
|
if (callback) {
|
|
246
255
|
ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
|
|
247
256
|
}
|
|
@@ -259,25 +268,15 @@ var ReactMount = {
|
|
|
259
268
|
* @return {ReactComponent} nextComponent
|
|
260
269
|
*/
|
|
261
270
|
_renderNewRootComponent: function (nextElement, container, shouldReuseMarkup, context) {
|
|
262
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
263
|
-
ReactInstrumentation.debugTool.onBeginFlush();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
271
|
// Various parts of our code (such as ReactCompositeComponent's
|
|
267
272
|
// _renderValidatedComponent) assume that calls to render aren't nested;
|
|
268
273
|
// verify that that's the case.
|
|
269
274
|
process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : void 0;
|
|
270
275
|
|
|
271
|
-
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') :
|
|
276
|
+
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : _prodInvariant('37') : void 0;
|
|
272
277
|
|
|
273
278
|
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
|
|
274
|
-
var componentInstance = instantiateReactComponent(nextElement);
|
|
275
|
-
|
|
276
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
277
|
-
// Mute future events from the top level wrapper.
|
|
278
|
-
// It is an implementation detail that devtools should not know about.
|
|
279
|
-
componentInstance._debugID = 0;
|
|
280
|
-
}
|
|
279
|
+
var componentInstance = instantiateReactComponent(nextElement, false);
|
|
281
280
|
|
|
282
281
|
// The initial render is synchronous but any updates that happen during
|
|
283
282
|
// rendering, in componentWillMount or componentDidMount, will be batched
|
|
@@ -291,7 +290,6 @@ var ReactMount = {
|
|
|
291
290
|
if (process.env.NODE_ENV !== 'production') {
|
|
292
291
|
// The instance here is TopLevelWrapper so we report mount for its child.
|
|
293
292
|
ReactInstrumentation.debugTool.onMountRootComponent(componentInstance._renderedComponent._debugID);
|
|
294
|
-
ReactInstrumentation.debugTool.onEndFlush();
|
|
295
293
|
}
|
|
296
294
|
|
|
297
295
|
return componentInstance;
|
|
@@ -311,7 +309,7 @@ var ReactMount = {
|
|
|
311
309
|
* @return {ReactComponent} Component instance rendered in `container`.
|
|
312
310
|
*/
|
|
313
311
|
renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
|
|
314
|
-
!(parentComponent != null && parentComponent
|
|
312
|
+
!(parentComponent != null && ReactInstanceMap.has(parentComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : _prodInvariant('38') : void 0;
|
|
315
313
|
return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
|
|
316
314
|
},
|
|
317
315
|
|
|
@@ -319,12 +317,20 @@ var ReactMount = {
|
|
|
319
317
|
ReactUpdateQueue.validateCallback(callback, 'ReactDOM.render');
|
|
320
318
|
!ReactElement.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOM.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing a string like \'div\', pass ' + 'React.createElement(\'div\') or <div />.' : typeof nextElement === 'function' ? ' Instead of passing a class like Foo, pass ' + 'React.createElement(Foo) or <Foo />.' :
|
|
321
319
|
// Check if it quacks like an element
|
|
322
|
-
nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') :
|
|
320
|
+
nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : _prodInvariant('39', typeof nextElement === 'string' ? ' Instead of passing a string like \'div\', pass ' + 'React.createElement(\'div\') or <div />.' : typeof nextElement === 'function' ? ' Instead of passing a class like Foo, pass ' + 'React.createElement(Foo) or <Foo />.' : nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : void 0;
|
|
323
321
|
|
|
324
322
|
process.env.NODE_ENV !== 'production' ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : void 0;
|
|
325
323
|
|
|
326
324
|
var nextWrappedElement = ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
|
|
327
325
|
|
|
326
|
+
var nextContext;
|
|
327
|
+
if (parentComponent) {
|
|
328
|
+
var parentInst = ReactInstanceMap.get(parentComponent);
|
|
329
|
+
nextContext = parentInst._processChildContext(parentInst._context);
|
|
330
|
+
} else {
|
|
331
|
+
nextContext = emptyObject;
|
|
332
|
+
}
|
|
333
|
+
|
|
328
334
|
var prevComponent = getTopLevelWrapperInContainer(container);
|
|
329
335
|
|
|
330
336
|
if (prevComponent) {
|
|
@@ -335,7 +341,7 @@ var ReactMount = {
|
|
|
335
341
|
var updatedCallback = callback && function () {
|
|
336
342
|
callback.call(publicInst);
|
|
337
343
|
};
|
|
338
|
-
ReactMount._updateRootComponent(prevComponent, nextWrappedElement, container, updatedCallback);
|
|
344
|
+
ReactMount._updateRootComponent(prevComponent, nextWrappedElement, nextContext, container, updatedCallback);
|
|
339
345
|
return publicInst;
|
|
340
346
|
} else {
|
|
341
347
|
ReactMount.unmountComponentAtNode(container);
|
|
@@ -362,7 +368,7 @@ var ReactMount = {
|
|
|
362
368
|
}
|
|
363
369
|
|
|
364
370
|
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent && !containerHasNonRootReactChild;
|
|
365
|
-
var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup,
|
|
371
|
+
var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, nextContext)._renderedComponent.getPublicInstance();
|
|
366
372
|
if (callback) {
|
|
367
373
|
callback.call(component);
|
|
368
374
|
}
|
|
@@ -401,7 +407,7 @@ var ReactMount = {
|
|
|
401
407
|
// render but we still don't expect to be in a render call here.)
|
|
402
408
|
process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : void 0;
|
|
403
409
|
|
|
404
|
-
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') :
|
|
410
|
+
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : _prodInvariant('40') : void 0;
|
|
405
411
|
|
|
406
412
|
var prevComponent = getTopLevelWrapperInContainer(container);
|
|
407
413
|
if (!prevComponent) {
|
|
@@ -424,7 +430,7 @@ var ReactMount = {
|
|
|
424
430
|
},
|
|
425
431
|
|
|
426
432
|
_mountImageIntoNode: function (markup, container, instance, shouldReuseMarkup, transaction) {
|
|
427
|
-
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') :
|
|
433
|
+
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : _prodInvariant('41') : void 0;
|
|
428
434
|
|
|
429
435
|
if (shouldReuseMarkup) {
|
|
430
436
|
var rootElement = getReactRootElementInContainer(container);
|
|
@@ -461,7 +467,7 @@ var ReactMount = {
|
|
|
461
467
|
var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
|
|
462
468
|
var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
|
|
463
469
|
|
|
464
|
-
!(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document using
|
|
470
|
+
!(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document using server rendering but the checksum was invalid. This usually means you rendered a different component type or props on the client from the one on the server, or your render() methods are impure. React cannot handle this case due to cross-browser quirks by rendering at the document root. You should look for environment dependent code in your components and ensure the props are the same client and server side:\n%s', difference) : _prodInvariant('42', difference) : void 0;
|
|
465
471
|
|
|
466
472
|
if (process.env.NODE_ENV !== 'production') {
|
|
467
473
|
process.env.NODE_ENV !== 'production' ? warning(false, 'React attempted to reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + 'or server:\n%s', difference) : void 0;
|
|
@@ -469,7 +475,7 @@ var ReactMount = {
|
|
|
469
475
|
}
|
|
470
476
|
}
|
|
471
477
|
|
|
472
|
-
!(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document but
|
|
478
|
+
!(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document but you didn\'t use server rendering. We can\'t do this without using server rendering due to cross-browser quirks. See ReactDOMServer.renderToString() for server rendering.') : _prodInvariant('43') : void 0;
|
|
473
479
|
|
|
474
480
|
if (transaction.useCreateElement) {
|
|
475
481
|
while (container.lastChild) {
|
|
@@ -482,9 +488,9 @@ var ReactMount = {
|
|
|
482
488
|
}
|
|
483
489
|
|
|
484
490
|
if (process.env.NODE_ENV !== 'production') {
|
|
485
|
-
var
|
|
486
|
-
if (
|
|
487
|
-
ReactInstrumentation.debugTool.
|
|
491
|
+
var hostNode = ReactDOMComponentTree.getInstanceFromNode(container.firstChild);
|
|
492
|
+
if (hostNode._debugID !== 0) {
|
|
493
|
+
ReactInstrumentation.debugTool.onHostOperation(hostNode._debugID, 'mount', markup.toString());
|
|
488
494
|
}
|
|
489
495
|
}
|
|
490
496
|
}
|
package/lib/ReactMultiChild.js
CHANGED
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
|
|
17
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
15
18
|
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
16
19
|
var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
|
|
17
20
|
|
|
@@ -55,7 +58,7 @@ function makeMove(child, afterNode, toIndex) {
|
|
|
55
58
|
type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
|
|
56
59
|
content: null,
|
|
57
60
|
fromIndex: child._mountIndex,
|
|
58
|
-
fromNode: ReactReconciler.
|
|
61
|
+
fromNode: ReactReconciler.getHostNode(child),
|
|
59
62
|
toIndex: toIndex,
|
|
60
63
|
afterNode: afterNode
|
|
61
64
|
};
|
|
@@ -136,12 +139,33 @@ function processQueue(inst, updateQueue) {
|
|
|
136
139
|
ReactComponentEnvironment.processChildrenUpdates(inst, updateQueue);
|
|
137
140
|
}
|
|
138
141
|
|
|
142
|
+
var setParentForInstrumentation = emptyFunction;
|
|
139
143
|
var setChildrenForInstrumentation = emptyFunction;
|
|
140
144
|
if (process.env.NODE_ENV !== 'production') {
|
|
145
|
+
var getDebugID = function (inst) {
|
|
146
|
+
if (!inst._debugID) {
|
|
147
|
+
// Check for ART-like instances. TODO: This is silly/gross.
|
|
148
|
+
var internal;
|
|
149
|
+
if (internal = ReactInstanceMap.get(inst)) {
|
|
150
|
+
inst = internal;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return inst._debugID;
|
|
154
|
+
};
|
|
155
|
+
setParentForInstrumentation = function (child) {
|
|
156
|
+
if (child._debugID !== 0) {
|
|
157
|
+
ReactInstrumentation.debugTool.onSetParent(child._debugID, getDebugID(this));
|
|
158
|
+
}
|
|
159
|
+
};
|
|
141
160
|
setChildrenForInstrumentation = function (children) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
161
|
+
var debugID = getDebugID(this);
|
|
162
|
+
// TODO: React Native empty components are also multichild.
|
|
163
|
+
// This means they still get into this method but don't have _debugID.
|
|
164
|
+
if (debugID !== 0) {
|
|
165
|
+
ReactInstrumentation.debugTool.onSetChildren(debugID, children ? Object.keys(children).map(function (key) {
|
|
166
|
+
return children[key]._debugID;
|
|
167
|
+
}) : []);
|
|
168
|
+
}
|
|
145
169
|
};
|
|
146
170
|
}
|
|
147
171
|
|
|
@@ -167,7 +191,7 @@ var ReactMultiChild = {
|
|
|
167
191
|
if (this._currentElement) {
|
|
168
192
|
try {
|
|
169
193
|
ReactCurrentOwner.current = this._currentElement._owner;
|
|
170
|
-
return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
|
|
194
|
+
return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context, this._debugID);
|
|
171
195
|
} finally {
|
|
172
196
|
ReactCurrentOwner.current = null;
|
|
173
197
|
}
|
|
@@ -182,7 +206,7 @@ var ReactMultiChild = {
|
|
|
182
206
|
if (this._currentElement) {
|
|
183
207
|
try {
|
|
184
208
|
ReactCurrentOwner.current = this._currentElement._owner;
|
|
185
|
-
nextChildren = flattenChildren(nextNestedChildrenElements);
|
|
209
|
+
nextChildren = flattenChildren(nextNestedChildrenElements, this._debugID);
|
|
186
210
|
} finally {
|
|
187
211
|
ReactCurrentOwner.current = null;
|
|
188
212
|
}
|
|
@@ -212,7 +236,10 @@ var ReactMultiChild = {
|
|
|
212
236
|
for (var name in children) {
|
|
213
237
|
if (children.hasOwnProperty(name)) {
|
|
214
238
|
var child = children[name];
|
|
215
|
-
|
|
239
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
240
|
+
setParentForInstrumentation.call(this, child);
|
|
241
|
+
}
|
|
242
|
+
var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context);
|
|
216
243
|
child._mountIndex = index++;
|
|
217
244
|
mountImages.push(mountImage);
|
|
218
245
|
}
|
|
@@ -237,7 +264,7 @@ var ReactMultiChild = {
|
|
|
237
264
|
ReactChildReconciler.unmountChildren(prevChildren, false);
|
|
238
265
|
for (var name in prevChildren) {
|
|
239
266
|
if (prevChildren.hasOwnProperty(name)) {
|
|
240
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') :
|
|
267
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') : _prodInvariant('118') : void 0;
|
|
241
268
|
}
|
|
242
269
|
}
|
|
243
270
|
// Set new text content.
|
|
@@ -257,7 +284,7 @@ var ReactMultiChild = {
|
|
|
257
284
|
ReactChildReconciler.unmountChildren(prevChildren, false);
|
|
258
285
|
for (var name in prevChildren) {
|
|
259
286
|
if (prevChildren.hasOwnProperty(name)) {
|
|
260
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') :
|
|
287
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updateTextContent called on non-empty component.') : _prodInvariant('118') : void 0;
|
|
261
288
|
}
|
|
262
289
|
}
|
|
263
290
|
var updates = [makeSetMarkup(nextMarkup)];
|
|
@@ -316,7 +343,7 @@ var ReactMultiChild = {
|
|
|
316
343
|
updates = enqueue(updates, this._mountChildAtIndex(nextChild, lastPlacedNode, nextIndex, transaction, context));
|
|
317
344
|
}
|
|
318
345
|
nextIndex++;
|
|
319
|
-
lastPlacedNode = ReactReconciler.
|
|
346
|
+
lastPlacedNode = ReactReconciler.getHostNode(nextChild);
|
|
320
347
|
}
|
|
321
348
|
// Remove children that are no longer present.
|
|
322
349
|
for (name in removedNodes) {
|
|
@@ -397,7 +424,7 @@ var ReactMultiChild = {
|
|
|
397
424
|
* @private
|
|
398
425
|
*/
|
|
399
426
|
_mountChildAtIndex: function (child, afterNode, index, transaction, context) {
|
|
400
|
-
var mountImage = ReactReconciler.mountComponent(child, transaction, this, this.
|
|
427
|
+
var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context);
|
|
401
428
|
child._mountIndex = index;
|
|
402
429
|
return this.createChild(child, afterNode, mountImage);
|
|
403
430
|
},
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
var ReactNativePropRegistry = require('./ReactNativePropRegistry');
|
|
15
15
|
|
|
16
|
-
var deepDiffer = require('deepDiffer');
|
|
17
|
-
var flattenStyle = require('flattenStyle');
|
|
16
|
+
var deepDiffer = require('react-native/lib/deepDiffer');
|
|
17
|
+
var flattenStyle = require('react-native/lib/flattenStyle');
|
|
18
18
|
|
|
19
19
|
var emptyObject = {};
|
|
20
20
|
|
|
@@ -282,6 +282,9 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
|
|
|
282
282
|
// default: fallthrough case when nested properties are defined
|
|
283
283
|
removedKeys = null;
|
|
284
284
|
removedKeyCount = 0;
|
|
285
|
+
// We think that attributeConfig is not CustomAttributeConfiguration at
|
|
286
|
+
// this point so we assume it must be AttributeConfiguration.
|
|
287
|
+
// $FlowFixMe
|
|
285
288
|
updatePayload = diffNestedProperty(updatePayload, prevProp, nextProp, attributeConfig);
|
|
286
289
|
if (removedKeyCount > 0 && updatePayload) {
|
|
287
290
|
restoreDeletedValuesInNestedArray(updatePayload, nextProp, attributeConfig);
|
|
@@ -19,9 +19,9 @@ var ReactNativeComponentTree = require('./ReactNativeComponentTree');
|
|
|
19
19
|
var ReactNativeEventEmitter = require('./ReactNativeEventEmitter');
|
|
20
20
|
var ReactNativeTagHandles = require('./ReactNativeTagHandles');
|
|
21
21
|
var ReactMultiChild = require('./ReactMultiChild');
|
|
22
|
-
var UIManager = require('UIManager');
|
|
22
|
+
var UIManager = require('react-native/lib/UIManager');
|
|
23
23
|
|
|
24
|
-
var deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev');
|
|
24
|
+
var deepFreezeAndThrowOnMutationInDev = require('react-native/lib/deepFreezeAndThrowOnMutationInDev');
|
|
25
25
|
|
|
26
26
|
var registrationNames = ReactNativeEventEmitter.registrationNames;
|
|
27
27
|
var putListener = ReactNativeEventEmitter.putListener;
|
|
@@ -150,7 +150,7 @@ ReactNativeBaseComponent.Mixin = {
|
|
|
150
150
|
*
|
|
151
151
|
* @return {null} Null.
|
|
152
152
|
*/
|
|
153
|
-
|
|
153
|
+
getHostNode: function () {
|
|
154
154
|
return this._rootNodeID;
|
|
155
155
|
},
|
|
156
156
|
|
|
@@ -159,12 +159,12 @@ ReactNativeBaseComponent.Mixin = {
|
|
|
159
159
|
* @param {Transaction} transaction For creating/updating.
|
|
160
160
|
* @return {string} Unique iOS view tag.
|
|
161
161
|
*/
|
|
162
|
-
mountComponent: function (transaction,
|
|
162
|
+
mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
|
|
163
163
|
var tag = ReactNativeTagHandles.allocateTag();
|
|
164
164
|
|
|
165
165
|
this._rootNodeID = tag;
|
|
166
|
-
this.
|
|
167
|
-
this.
|
|
166
|
+
this._hostParent = hostParent;
|
|
167
|
+
this._hostContainerInfo = hostContainerInfo;
|
|
168
168
|
|
|
169
169
|
if (process.env.NODE_ENV !== 'production') {
|
|
170
170
|
for (var key in this.viewConfig.validAttributes) {
|
|
@@ -176,7 +176,7 @@ ReactNativeBaseComponent.Mixin = {
|
|
|
176
176
|
|
|
177
177
|
var updatePayload = ReactNativeAttributePayload.create(this._currentElement.props, this.viewConfig.validAttributes);
|
|
178
178
|
|
|
179
|
-
var nativeTopRootTag =
|
|
179
|
+
var nativeTopRootTag = hostContainerInfo._tag;
|
|
180
180
|
UIManager.createView(tag, this.viewConfig.uiViewClassName, nativeTopRootTag, updatePayload);
|
|
181
181
|
|
|
182
182
|
ReactNativeComponentTree.precacheNode(this, tag);
|