mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Cleanup ReactChildren
This commit is contained in:
committed by
Paul O’Shannessy
parent
1aa9cc6a8b
commit
022e44c95b
@@ -129,19 +129,19 @@ function mapChildren(children, func, context) {
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of children that are typically specified as
|
||||
* `props.children`.
|
||||
*/
|
||||
|
||||
function forEachSingleChildDummy(traverseContext, child, name, i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function countChildren(children, context) {
|
||||
var numberOfChildren = traverseAllChildren(children, forEachSingleChildDummy,
|
||||
null);
|
||||
return numberOfChildren;
|
||||
/**
|
||||
* Count the number of children that are typically specified as
|
||||
* `props.children`.
|
||||
*
|
||||
* @param {?*} children Children tree container.
|
||||
* @return {number} The number of children.
|
||||
*/
|
||||
function countChildren(children, context) {
|
||||
return traverseAllChildren(children, forEachSingleChildDummy, null);
|
||||
}
|
||||
|
||||
var ReactChildren = {
|
||||
|
||||
@@ -183,12 +183,11 @@ var traverseAllChildrenImpl =
|
||||
* @return {!number} The number of children in this subtree.
|
||||
*/
|
||||
function traverseAllChildren(children, callback, traverseContext) {
|
||||
if (children !== null && children !== undefined) {
|
||||
return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
|
||||
}
|
||||
else {
|
||||
if (children == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
|
||||
}
|
||||
|
||||
module.exports = traverseAllChildren;
|
||||
|
||||
Reference in New Issue
Block a user