Skip to content

Commit

Permalink
Merge pull request #4408 from jimfb/remove-children-map
Browse files Browse the repository at this point in the history
Removed flattened children object.  Fixes #4405
  • Loading branch information
jimfb committed Jul 18, 2015
2 parents 2ea0bd7 + fe99e59 commit c73f952
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/renderers/shared/reconciler/ReactChildReconciler.js
Expand Up @@ -17,14 +17,32 @@ var ReactReconciler = require('ReactReconciler');
var flattenChildren = require('flattenChildren');
var instantiateReactComponent = require('instantiateReactComponent');
var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
var traverseAllChildren = require('traverseAllChildren');
var warning = require('warning');

function instantiateChild(childInstances, child, name) {
// We found a component instance.
var keyUnique = (childInstances[name] === undefined);
if (__DEV__) {
warning(
keyUnique,
'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.',
name
);
}
if (child != null && keyUnique) {
childInstances[name] = instantiateReactComponent(child, null);
}
}

/**
* ReactChildReconciler provides helpers for initializing or updating a set of
* children. Its output is suitable for passing it onto ReactMultiChild which
* does diffed reordering and insertion.
*/
var ReactChildReconciler = {

/**
* Generates a "mount image" for each of the supplied children. In the case
* of `ReactDOMComponent`, a mount image is a string of markup.
Expand All @@ -34,17 +52,12 @@ var ReactChildReconciler = {
* @internal
*/
instantiateChildren: function(nestedChildNodes, transaction, context) {
var children = flattenChildren(nestedChildNodes);
for (var name in children) {
if (children.hasOwnProperty(name)) {
var child = children[name];
// The rendered children must be turned into instances as they're
// mounted.
var childInstance = instantiateReactComponent(child, null);
children[name] = childInstance;
}
if (nestedChildNodes == null) {
return null;
}
return children;
var childInstances = {};
traverseAllChildren(nestedChildNodes, instantiateChild, childInstances);
return childInstances;
},

/**
Expand Down

0 comments on commit c73f952

Please sign in to comment.