@samitouri / QOS-React-2 / commits / 27669c09ca

Move flattenChildren into MultiChild

Sebastian Markbage committed Oct 7, 2013 at 14:56 UTC 27669c09ca68febf7dcfc1cc992f109706c70c00
2 files changed +13 -10
src/core/ReactDOMComponent.js
+2 -3
@@ -29,7 +29,6 @@ var ReactMount = require('ReactMount');
29 var ReactPerf = require('ReactPerf');
30
31 var escapeTextForBrowser = require('escapeTextForBrowser');
32 -var flattenChildren = require('flattenChildren');
32 var invariant = require('invariant');
33 var keyOf = require('keyOf');
34 var merge = require('merge');
@@ -171,7 +170,7 @@ ReactDOMComponent.Mixin = {
170 return escapeTextForBrowser(contentToUse);
171 } else if (childrenToUse != null) {
172 var mountImages = this.mountChildren(
174 - flattenChildren(childrenToUse),
173 + childrenToUse,
174 transaction
175 );
176 return mountImages.join('');
@@ -346,7 +345,7 @@ ReactDOMComponent.Mixin = {
345 );
346 }
347 } else if (nextChildren != null) {
349 - this.updateChildren(flattenChildren(nextChildren), transaction);
348 + this.updateChildren(nextChildren, transaction);
349 }
350 },
351
src/core/ReactMultiChild.js
+11 -7
@@ -22,6 +22,8 @@
22 var ReactComponent = require('ReactComponent');
23 var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
24
25 +var flattenChildren = require('flattenChildren');
26 +
27 /**
28 * Given a `curChild` and `newChild`, determines if `curChild` should be
29 * updated as opposed to being destroyed or replaced.
@@ -190,11 +192,12 @@ var ReactMultiChild = {
192 * Generates a "mount image" for each of the supplied children. In the case
193 * of `ReactDOMComponent`, a mount image is a string of markup.
194 *
193 - * @param {?object} children As returned by `flattenChildren`.
195 + * @param {?object} nestedChildren Nested child maps.
196 * @return {array} An array of mounted representations.
197 * @internal
198 */
197 - mountChildren: function(children, transaction) {
199 + mountChildren: function(nestedChildren, transaction) {
200 + var children = flattenChildren(nestedChildren);
201 var mountImages = [];
202 var index = 0;
203 this._renderedChildren = children;
@@ -248,14 +251,14 @@ var ReactMultiChild = {
251 /**
252 * Updates the rendered children with new children.
253 *
251 - * @param {?object} nextChildren As returned by `flattenChildren`.
254 + * @param {?object} nextNestedChildren Nested child maps.
255 * @param {ReactReconcileTransaction} transaction
256 * @internal
257 */
255 - updateChildren: function(nextChildren, transaction) {
258 + updateChildren: function(nextNestedChildren, transaction) {
259 updateDepth++;
260 try {
258 - this._updateChildren(nextChildren, transaction);
261 + this._updateChildren(nextNestedChildren, transaction);
262 } catch (error) {
263 updateDepth--;
264 updateDepth || clearQueue();
@@ -269,12 +272,13 @@ var ReactMultiChild = {
272 * Improve performance by isolating this hot code path from the try/catch
273 * block in `updateChildren`.
274 *
272 - * @param {?object} nextChildren As returned by `flattenChildren`.
275 + * @param {?object} nextNestedChildren Nested child maps.
276 * @param {ReactReconcileTransaction} transaction
277 * @final
278 * @protected
279 */
277 - _updateChildren: function(nextChildren, transaction) {
280 + _updateChildren: function(nextNestedChildren, transaction) {
281 + var nextChildren = flattenChildren(nextNestedChildren);
282 var prevChildren = this._renderedChildren;
283 if (!nextChildren && !prevChildren) {
284 return;