react 15.2.0 → 15.3.0-rc.3
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 +1572 -1136
- package/dist/react-with-addons.min.js +6 -7
- package/dist/react.js +1495 -1064
- package/dist/react.min.js +6 -6
- package/lib/DOMProperty.js +0 -9
- package/lib/DOMPropertyOperations.js +4 -12
- package/lib/Danger.js +0 -98
- package/lib/EventPluginHub.js +14 -6
- package/lib/HTMLDOMPropertyConfig.js +1 -0
- package/lib/KeyEscapeUtils.js +2 -1
- package/lib/LinkedValueUtils.js +2 -1
- package/lib/NativeMethodsMixin.js +1 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +2 -0
- package/lib/ReactChildReconciler.js +21 -4
- package/lib/ReactChildrenMutationWarningDevtool.js +62 -0
- package/lib/ReactClass.js +7 -0
- package/lib/ReactComponentTreeDevtool.js +0 -5
- package/lib/ReactCompositeComponent.js +94 -33
- package/lib/ReactDOM.js +2 -2
- package/lib/ReactDOMComponent.js +23 -1
- package/lib/ReactDOMDebugTool.js +11 -11
- package/lib/ReactDOMFiber.js +78 -0
- package/lib/ReactDOMInput.js +21 -16
- package/lib/ReactDOMInstrumentation.js +7 -2
- package/lib/ReactDOMNullInputValuePropDevtool.js +43 -0
- package/lib/ReactDOMSelect.js +0 -13
- package/lib/ReactDOMTextarea.js +0 -14
- package/lib/ReactDebugTool.js +95 -85
- package/lib/ReactElement.js +8 -0
- package/lib/ReactFeatureFlags.js +1 -0
- package/lib/ReactInstrumentation.js +7 -2
- package/lib/ReactMount.js +15 -17
- package/lib/ReactMultiChild.js +19 -11
- package/lib/ReactNativeMount.js +2 -13
- package/lib/ReactNativeReconcileTransaction.js +16 -0
- package/lib/ReactNodeTypes.js +1 -0
- package/lib/ReactNoop.js +100 -3
- package/lib/ReactNoopUpdateQueue.js +6 -5
- package/lib/ReactPropTypes.js +28 -14
- package/lib/ReactPropTypesSecret.js +16 -0
- package/lib/ReactPureComponent.js +42 -0
- package/lib/ReactReconcileTransaction.js +16 -0
- package/lib/ReactReconciler.js +2 -4
- package/lib/ReactRef.js +3 -1
- package/lib/ReactServerRendering.js +9 -6
- package/lib/ReactServerRenderingTransaction.js +17 -0
- package/lib/ReactServerUpdateQueue.js +141 -0
- package/lib/ReactTestMount.js +29 -27
- package/lib/ReactTestReconcileTransaction.js +8 -0
- package/lib/ReactTestRenderer.js +11 -0
- package/lib/ReactTestUtils.js +7 -3
- package/lib/ReactTransitionGroup.js +1 -0
- package/lib/ReactUpdateQueue.js +6 -3
- package/lib/ReactUpdates.js +1 -10
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +1 -1
- package/lib/ResponderTouchHistoryStore.js +97 -95
- package/lib/SVGDOMPropertyConfig.js +2 -0
- package/lib/SimpleEventPlugin.js +10 -6
- package/lib/accumulate.js +14 -14
- package/lib/accumulateInto.js +8 -11
- package/lib/adler32.js +1 -0
- package/lib/checkReactTypeSpec.js +22 -6
- package/lib/deprecated.js +7 -1
- package/lib/flattenChildren.js +24 -8
- package/lib/forEachAccumulated.js +3 -2
- package/lib/getIteratorFn.js +1 -0
- package/lib/instantiateReactComponent.js +8 -7
- package/lib/isTextInputElement.js +11 -1
- package/lib/reactProdInvariant.js +1 -0
- package/lib/traverseAllChildren.js +8 -1
- package/package.json +1 -1
package/lib/ReactElement.js
CHANGED
|
@@ -97,6 +97,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
97
97
|
// This can be replaced with a WeakMap once they are implemented in
|
|
98
98
|
// commonly used development environments.
|
|
99
99
|
element._store = {};
|
|
100
|
+
var shadowChildren = Array.isArray(props.children) ? props.children.slice(0) : props.children;
|
|
100
101
|
|
|
101
102
|
// To make comparing ReactElements easier for testing purposes, we make
|
|
102
103
|
// the validation flag non-enumerable (where possible, which should
|
|
@@ -116,6 +117,12 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
116
117
|
writable: false,
|
|
117
118
|
value: self
|
|
118
119
|
});
|
|
120
|
+
Object.defineProperty(element, '_shadowChildren', {
|
|
121
|
+
configurable: false,
|
|
122
|
+
enumerable: false,
|
|
123
|
+
writable: false,
|
|
124
|
+
value: shadowChildren
|
|
125
|
+
});
|
|
119
126
|
// Two elements created in two different places should be considered
|
|
120
127
|
// equal for testing purposes and therefore we hide it from enumeration.
|
|
121
128
|
Object.defineProperty(element, '_source', {
|
|
@@ -127,6 +134,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
127
134
|
} else {
|
|
128
135
|
element._store.validated = false;
|
|
129
136
|
element._self = self;
|
|
137
|
+
element._shadowChildren = shadowChildren;
|
|
130
138
|
element._source = source;
|
|
131
139
|
}
|
|
132
140
|
if (Object.freeze) {
|
package/lib/ReactFeatureFlags.js
CHANGED
|
@@ -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
|
@@ -22,6 +22,7 @@ var ReactDOMContainerInfo = require('./ReactDOMContainerInfo');
|
|
|
22
22
|
var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
|
|
23
23
|
var ReactElement = require('./ReactElement');
|
|
24
24
|
var ReactFeatureFlags = require('./ReactFeatureFlags');
|
|
25
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
25
26
|
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
26
27
|
var ReactMarkupChecksum = require('./ReactMarkupChecksum');
|
|
27
28
|
var ReactReconciler = require('./ReactReconciler');
|
|
@@ -247,9 +248,9 @@ var ReactMount = {
|
|
|
247
248
|
* @param {DOMElement} container container to render into
|
|
248
249
|
* @param {?function} callback function triggered on completion
|
|
249
250
|
*/
|
|
250
|
-
_updateRootComponent: function (prevComponent, nextElement, container, callback) {
|
|
251
|
+
_updateRootComponent: function (prevComponent, nextElement, nextContext, container, callback) {
|
|
251
252
|
ReactMount.scrollMonitor(container, function () {
|
|
252
|
-
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
|
|
253
|
+
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement, nextContext);
|
|
253
254
|
if (callback) {
|
|
254
255
|
ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
|
|
255
256
|
}
|
|
@@ -267,10 +268,6 @@ var ReactMount = {
|
|
|
267
268
|
* @return {ReactComponent} nextComponent
|
|
268
269
|
*/
|
|
269
270
|
_renderNewRootComponent: function (nextElement, container, shouldReuseMarkup, context) {
|
|
270
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
271
|
-
ReactInstrumentation.debugTool.onBeginFlush();
|
|
272
|
-
}
|
|
273
|
-
|
|
274
271
|
// Various parts of our code (such as ReactCompositeComponent's
|
|
275
272
|
// _renderValidatedComponent) assume that calls to render aren't nested;
|
|
276
273
|
// verify that that's the case.
|
|
@@ -279,13 +276,7 @@ var ReactMount = {
|
|
|
279
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;
|
|
280
277
|
|
|
281
278
|
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
|
|
282
|
-
var componentInstance = instantiateReactComponent(nextElement);
|
|
283
|
-
|
|
284
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
285
|
-
// Mute future events from the top level wrapper.
|
|
286
|
-
// It is an implementation detail that devtools should not know about.
|
|
287
|
-
componentInstance._debugID = 0;
|
|
288
|
-
}
|
|
279
|
+
var componentInstance = instantiateReactComponent(nextElement, false);
|
|
289
280
|
|
|
290
281
|
// The initial render is synchronous but any updates that happen during
|
|
291
282
|
// rendering, in componentWillMount or componentDidMount, will be batched
|
|
@@ -299,7 +290,6 @@ var ReactMount = {
|
|
|
299
290
|
if (process.env.NODE_ENV !== 'production') {
|
|
300
291
|
// The instance here is TopLevelWrapper so we report mount for its child.
|
|
301
292
|
ReactInstrumentation.debugTool.onMountRootComponent(componentInstance._renderedComponent._debugID);
|
|
302
|
-
ReactInstrumentation.debugTool.onEndFlush();
|
|
303
293
|
}
|
|
304
294
|
|
|
305
295
|
return componentInstance;
|
|
@@ -319,7 +309,7 @@ var ReactMount = {
|
|
|
319
309
|
* @return {ReactComponent} Component instance rendered in `container`.
|
|
320
310
|
*/
|
|
321
311
|
renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
|
|
322
|
-
!(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;
|
|
323
313
|
return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
|
|
324
314
|
},
|
|
325
315
|
|
|
@@ -333,6 +323,14 @@ var ReactMount = {
|
|
|
333
323
|
|
|
334
324
|
var nextWrappedElement = ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
|
|
335
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
|
+
|
|
336
334
|
var prevComponent = getTopLevelWrapperInContainer(container);
|
|
337
335
|
|
|
338
336
|
if (prevComponent) {
|
|
@@ -343,7 +341,7 @@ var ReactMount = {
|
|
|
343
341
|
var updatedCallback = callback && function () {
|
|
344
342
|
callback.call(publicInst);
|
|
345
343
|
};
|
|
346
|
-
ReactMount._updateRootComponent(prevComponent, nextWrappedElement, container, updatedCallback);
|
|
344
|
+
ReactMount._updateRootComponent(prevComponent, nextWrappedElement, nextContext, container, updatedCallback);
|
|
347
345
|
return publicInst;
|
|
348
346
|
} else {
|
|
349
347
|
ReactMount.unmountComponentAtNode(container);
|
|
@@ -370,7 +368,7 @@ var ReactMount = {
|
|
|
370
368
|
}
|
|
371
369
|
|
|
372
370
|
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent && !containerHasNonRootReactChild;
|
|
373
|
-
var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup,
|
|
371
|
+
var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, nextContext)._renderedComponent.getPublicInstance();
|
|
374
372
|
if (callback) {
|
|
375
373
|
callback.call(component);
|
|
376
374
|
}
|
package/lib/ReactMultiChild.js
CHANGED
|
@@ -158,9 +158,14 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
160
|
setChildrenForInstrumentation = function (children) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
+
}
|
|
164
169
|
};
|
|
165
170
|
}
|
|
166
171
|
|
|
@@ -195,7 +200,7 @@ var ReactMultiChild = {
|
|
|
195
200
|
return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
|
|
196
201
|
},
|
|
197
202
|
|
|
198
|
-
_reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, removedNodes, transaction, context) {
|
|
203
|
+
_reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context) {
|
|
199
204
|
var nextChildren;
|
|
200
205
|
if (process.env.NODE_ENV !== 'production') {
|
|
201
206
|
if (this._currentElement) {
|
|
@@ -205,12 +210,12 @@ var ReactMultiChild = {
|
|
|
205
210
|
} finally {
|
|
206
211
|
ReactCurrentOwner.current = null;
|
|
207
212
|
}
|
|
208
|
-
ReactChildReconciler.updateChildren(prevChildren, nextChildren, removedNodes, transaction, context);
|
|
213
|
+
ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context);
|
|
209
214
|
return nextChildren;
|
|
210
215
|
}
|
|
211
216
|
}
|
|
212
217
|
nextChildren = flattenChildren(nextNestedChildrenElements);
|
|
213
|
-
ReactChildReconciler.updateChildren(prevChildren, nextChildren, removedNodes, transaction, context);
|
|
218
|
+
ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context);
|
|
214
219
|
return nextChildren;
|
|
215
220
|
},
|
|
216
221
|
|
|
@@ -307,7 +312,8 @@ var ReactMultiChild = {
|
|
|
307
312
|
_updateChildren: function (nextNestedChildrenElements, transaction, context) {
|
|
308
313
|
var prevChildren = this._renderedChildren;
|
|
309
314
|
var removedNodes = {};
|
|
310
|
-
var
|
|
315
|
+
var mountImages = [];
|
|
316
|
+
var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context);
|
|
311
317
|
if (!nextChildren && !prevChildren) {
|
|
312
318
|
return;
|
|
313
319
|
}
|
|
@@ -315,8 +321,10 @@ var ReactMultiChild = {
|
|
|
315
321
|
var name;
|
|
316
322
|
// `nextIndex` will increment for each child in `nextChildren`, but
|
|
317
323
|
// `lastIndex` will be the last index visited in `prevChildren`.
|
|
318
|
-
var lastIndex = 0;
|
|
319
324
|
var nextIndex = 0;
|
|
325
|
+
var lastIndex = 0;
|
|
326
|
+
// `nextMountIndex` will increment for each newly mounted child.
|
|
327
|
+
var nextMountIndex = 0;
|
|
320
328
|
var lastPlacedNode = null;
|
|
321
329
|
for (name in nextChildren) {
|
|
322
330
|
if (!nextChildren.hasOwnProperty(name)) {
|
|
@@ -335,7 +343,8 @@ var ReactMultiChild = {
|
|
|
335
343
|
// The `removedNodes` loop below will actually remove the child.
|
|
336
344
|
}
|
|
337
345
|
// The child must be instantiated before it's mounted.
|
|
338
|
-
updates = enqueue(updates, this._mountChildAtIndex(nextChild, lastPlacedNode, nextIndex, transaction, context));
|
|
346
|
+
updates = enqueue(updates, this._mountChildAtIndex(nextChild, mountImages[nextMountIndex], lastPlacedNode, nextIndex, transaction, context));
|
|
347
|
+
nextMountIndex++;
|
|
339
348
|
}
|
|
340
349
|
nextIndex++;
|
|
341
350
|
lastPlacedNode = ReactReconciler.getHostNode(nextChild);
|
|
@@ -418,8 +427,7 @@ var ReactMultiChild = {
|
|
|
418
427
|
* @param {ReactReconcileTransaction} transaction
|
|
419
428
|
* @private
|
|
420
429
|
*/
|
|
421
|
-
_mountChildAtIndex: function (child, afterNode, index, transaction, context) {
|
|
422
|
-
var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context);
|
|
430
|
+
_mountChildAtIndex: function (child, mountImage, afterNode, index, transaction, context) {
|
|
423
431
|
child._mountIndex = index;
|
|
424
432
|
return this.createChild(child, afterNode, mountImage);
|
|
425
433
|
},
|
package/lib/ReactNativeMount.js
CHANGED
|
@@ -89,7 +89,7 @@ var ReactNativeMount = {
|
|
|
89
89
|
var prevWrappedElement = prevComponent._currentElement;
|
|
90
90
|
var prevElement = prevWrappedElement.props;
|
|
91
91
|
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
92
|
-
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextWrappedElement);
|
|
92
|
+
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextWrappedElement, emptyObject);
|
|
93
93
|
if (callback) {
|
|
94
94
|
ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
|
|
95
95
|
}
|
|
@@ -106,19 +106,9 @@ var ReactNativeMount = {
|
|
|
106
106
|
|
|
107
107
|
ReactNativeTagHandles.assertRootTag(containerTag);
|
|
108
108
|
|
|
109
|
-
var instance = instantiateReactComponent(nextWrappedElement);
|
|
109
|
+
var instance = instantiateReactComponent(nextWrappedElement, false);
|
|
110
110
|
ReactNativeMount._instancesByContainerID[containerTag] = instance;
|
|
111
111
|
|
|
112
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
113
|
-
// Mute future events from the top level wrapper.
|
|
114
|
-
// It is an implementation detail that devtools should not know about.
|
|
115
|
-
instance._debugID = 0;
|
|
116
|
-
|
|
117
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
118
|
-
ReactInstrumentation.debugTool.onBeginFlush();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
112
|
// The initial render is synchronous but any updates that happen during
|
|
123
113
|
// rendering, in componentWillMount or componentDidMount, will be batched
|
|
124
114
|
// according to the current batching strategy.
|
|
@@ -127,7 +117,6 @@ var ReactNativeMount = {
|
|
|
127
117
|
if (process.env.NODE_ENV !== 'production') {
|
|
128
118
|
// The instance here is TopLevelWrapper so we report mount for its child.
|
|
129
119
|
ReactInstrumentation.debugTool.onMountRootComponent(instance._renderedComponent._debugID);
|
|
130
|
-
ReactInstrumentation.debugTool.onEndFlush();
|
|
131
120
|
}
|
|
132
121
|
var component = instance.getPublicInstance();
|
|
133
122
|
if (callback) {
|
|
@@ -16,6 +16,8 @@ var _assign = require('object-assign');
|
|
|
16
16
|
var CallbackQueue = require('./CallbackQueue');
|
|
17
17
|
var PooledClass = require('./PooledClass');
|
|
18
18
|
var Transaction = require('./Transaction');
|
|
19
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
20
|
+
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks during
|
|
@@ -44,6 +46,13 @@ var ON_DOM_READY_QUEUEING = {
|
|
|
44
46
|
*/
|
|
45
47
|
var TRANSACTION_WRAPPERS = [ON_DOM_READY_QUEUEING];
|
|
46
48
|
|
|
49
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
50
|
+
TRANSACTION_WRAPPERS.push({
|
|
51
|
+
initialize: ReactInstrumentation.debugTool.onBeginFlush,
|
|
52
|
+
close: ReactInstrumentation.debugTool.onEndFlush
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
47
56
|
/**
|
|
48
57
|
* Currently:
|
|
49
58
|
* - The order that these are listed in the transaction is critical:
|
|
@@ -83,6 +92,13 @@ var Mixin = {
|
|
|
83
92
|
return this.reactMountReady;
|
|
84
93
|
},
|
|
85
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @return {object} The queue to collect React async events.
|
|
97
|
+
*/
|
|
98
|
+
getUpdateQueue: function () {
|
|
99
|
+
return ReactUpdateQueue;
|
|
100
|
+
},
|
|
101
|
+
|
|
86
102
|
/**
|
|
87
103
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
88
104
|
* instance to be reused.
|
package/lib/ReactNodeTypes.js
CHANGED
package/lib/ReactNoop.js
CHANGED
|
@@ -24,8 +24,59 @@ var ReactFiberReconciler = require('./ReactFiberReconciler');
|
|
|
24
24
|
var scheduledHighPriCallback = null;
|
|
25
25
|
var scheduledLowPriCallback = null;
|
|
26
26
|
|
|
27
|
+
var TERMINAL_TAG = 99;
|
|
28
|
+
|
|
29
|
+
var instanceCounter = 0;
|
|
30
|
+
|
|
31
|
+
function recursivelyAppendChildren(flatArray, child) {
|
|
32
|
+
if (!child) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (child.tag === TERMINAL_TAG) {
|
|
36
|
+
flatArray.push(child);
|
|
37
|
+
} else {
|
|
38
|
+
var node = child;
|
|
39
|
+
do {
|
|
40
|
+
recursivelyAppendChildren(flatArray, node.output);
|
|
41
|
+
} while (node = node.sibling);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function flattenChildren(children) {
|
|
46
|
+
var flatArray = [];
|
|
47
|
+
recursivelyAppendChildren(flatArray, children);
|
|
48
|
+
return flatArray;
|
|
49
|
+
}
|
|
50
|
+
|
|
27
51
|
var NoopRenderer = ReactFiberReconciler({
|
|
28
|
-
|
|
52
|
+
updateContainer: function (containerInfo, children) {
|
|
53
|
+
console.log('Update container #' + containerInfo.rootID);
|
|
54
|
+
containerInfo.children = flattenChildren(children);
|
|
55
|
+
},
|
|
56
|
+
createInstance: function (type, props, children) {
|
|
57
|
+
console.log('Create instance #' + instanceCounter);
|
|
58
|
+
var inst = {
|
|
59
|
+
tag: TERMINAL_TAG,
|
|
60
|
+
id: instanceCounter++,
|
|
61
|
+
type: type,
|
|
62
|
+
children: flattenChildren(children)
|
|
63
|
+
};
|
|
64
|
+
// Hide from unit tests
|
|
65
|
+
Object.defineProperty(inst, 'tag', { value: inst.tag, enumerable: false });
|
|
66
|
+
Object.defineProperty(inst, 'id', { value: inst.id, enumerable: false });
|
|
67
|
+
return inst;
|
|
68
|
+
},
|
|
69
|
+
prepareUpdate: function (instance, oldProps, newProps, children) {
|
|
70
|
+
console.log('Prepare for update on #' + instance.id);
|
|
71
|
+
return true;
|
|
72
|
+
},
|
|
73
|
+
commitUpdate: function (instance, oldProps, newProps, children) {
|
|
74
|
+
console.log('Commit update on #' + instance.id);
|
|
75
|
+
instance.children = flattenChildren(children);
|
|
76
|
+
},
|
|
77
|
+
deleteInstance: function (instance) {
|
|
78
|
+
console.log('Delete #' + instance.id);
|
|
79
|
+
},
|
|
29
80
|
scheduleHighPriCallback: function (callback) {
|
|
30
81
|
scheduledHighPriCallback = callback;
|
|
31
82
|
},
|
|
@@ -34,10 +85,20 @@ var NoopRenderer = ReactFiberReconciler({
|
|
|
34
85
|
}
|
|
35
86
|
});
|
|
36
87
|
|
|
88
|
+
var rootContainer = { rootID: 0, children: [] };
|
|
89
|
+
|
|
90
|
+
var root = null;
|
|
91
|
+
|
|
37
92
|
var ReactNoop = {
|
|
38
|
-
render: function (element) {
|
|
39
93
|
|
|
40
|
-
|
|
94
|
+
root: rootContainer,
|
|
95
|
+
|
|
96
|
+
render: function (element) {
|
|
97
|
+
if (!root) {
|
|
98
|
+
root = NoopRenderer.mountContainer(element, rootContainer);
|
|
99
|
+
} else {
|
|
100
|
+
NoopRenderer.updateContainer(element, root);
|
|
101
|
+
}
|
|
41
102
|
},
|
|
42
103
|
flushHighPri: function () {
|
|
43
104
|
var cb = scheduledHighPriCallback;
|
|
@@ -70,6 +131,42 @@ var ReactNoop = {
|
|
|
70
131
|
flush: function () {
|
|
71
132
|
ReactNoop.flushHighPri();
|
|
72
133
|
ReactNoop.flushLowPri();
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
// Logs the current state of the tree.
|
|
138
|
+
dumpTree: function () {
|
|
139
|
+
if (!root) {
|
|
140
|
+
console.log('Nothing rendered yet.');
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function logHostInstances(children, depth) {
|
|
145
|
+
for (var i = 0; i < children.length; i++) {
|
|
146
|
+
var child = children[i];
|
|
147
|
+
console.log(' '.repeat(depth) + '- ' + child.type + '#' + child.id);
|
|
148
|
+
logHostInstances(child.children, depth + 1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function logContainer(container, depth) {
|
|
152
|
+
console.log(' '.repeat(depth) + '- [root#' + container.rootID + ']');
|
|
153
|
+
logHostInstances(container.children, depth + 1);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function logFiber(fiber, depth) {
|
|
157
|
+
console.log(' '.repeat(depth) + '- ' + (fiber.type ? fiber.type.name || fiber.type : '[root]'), '[' + fiber.pendingWorkPriority + (fiber.pendingProps ? '*' : '') + ']');
|
|
158
|
+
if (fiber.child) {
|
|
159
|
+
logFiber(fiber.child, depth + 1);
|
|
160
|
+
}
|
|
161
|
+
if (fiber.sibling) {
|
|
162
|
+
logFiber(fiber.sibling, depth);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
console.log('HOST INSTANCES:');
|
|
167
|
+
logContainer(rootContainer, 0);
|
|
168
|
+
console.log('FIBERS:');
|
|
169
|
+
logFiber(root.stateNode.current, 0);
|
|
73
170
|
}
|
|
74
171
|
};
|
|
75
172
|
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
|
|
14
14
|
var warning = require('fbjs/lib/warning');
|
|
15
15
|
|
|
16
|
-
function
|
|
16
|
+
function warnNoop(publicInstance, callerName) {
|
|
17
17
|
if (process.env.NODE_ENV !== 'production') {
|
|
18
|
-
|
|
18
|
+
var constructor = publicInstance.constructor;
|
|
19
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass') : void 0;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -59,7 +60,7 @@ var ReactNoopUpdateQueue = {
|
|
|
59
60
|
* @internal
|
|
60
61
|
*/
|
|
61
62
|
enqueueForceUpdate: function (publicInstance) {
|
|
62
|
-
|
|
63
|
+
warnNoop(publicInstance, 'forceUpdate');
|
|
63
64
|
},
|
|
64
65
|
|
|
65
66
|
/**
|
|
@@ -74,7 +75,7 @@ var ReactNoopUpdateQueue = {
|
|
|
74
75
|
* @internal
|
|
75
76
|
*/
|
|
76
77
|
enqueueReplaceState: function (publicInstance, completeState) {
|
|
77
|
-
|
|
78
|
+
warnNoop(publicInstance, 'replaceState');
|
|
78
79
|
},
|
|
79
80
|
|
|
80
81
|
/**
|
|
@@ -88,7 +89,7 @@ var ReactNoopUpdateQueue = {
|
|
|
88
89
|
* @internal
|
|
89
90
|
*/
|
|
90
91
|
enqueueSetState: function (publicInstance, partialState) {
|
|
91
|
-
|
|
92
|
+
warnNoop(publicInstance, 'setState');
|
|
92
93
|
}
|
|
93
94
|
};
|
|
94
95
|
|