@samitouri / QOS-React-2 / commits / ea2496b6f6

traverseAllChildren code clarity

Bartosz Kaszubowski committed Jul 13, 2015 at 23:45 UTC ea2496b6f6bd8fc169bd7b9d2aaa6f90eaa19a6f
1 file changed +5 -10
src/shared/utils/traverseAllChildren.js
+5 -10
@@ -119,14 +119,12 @@ function traverseAllChildrenImpl(
119 var child;
120 var nextName;
121 var subtreeCount = 0; // Count of children found in the current subtree.
122 + var nextNamePrefix = nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR;
123
124 if (Array.isArray(children)) {
125 for (var i = 0; i < children.length; i++) {
126 child = children[i];
126 - nextName = (
127 - (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
128 - getComponentKey(child, i)
129 - );
127 + nextName = nextNamePrefix + getComponentKey(child, i);
128 subtreeCount += traverseAllChildrenImpl(
129 child,
130 nextName,
@@ -143,10 +141,7 @@ function traverseAllChildrenImpl(
141 var ii = 0;
142 while (!(step = iterator.next()).done) {
143 child = step.value;
146 - nextName = (
147 - (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
148 - getComponentKey(child, ii++)
149 - );
144 + nextName = nextNamePrefix + getComponentKey(child, ii++);
145 subtreeCount += traverseAllChildrenImpl(
146 child,
147 nextName,
@@ -170,7 +165,7 @@ function traverseAllChildrenImpl(
165 if (entry) {
166 child = entry[1];
167 nextName = (
173 - (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
168 + nextNamePrefix +
169 wrapUserProvidedKey(entry[0]) + SUBSEPARATOR +
170 getComponentKey(child, 0)
171 );
@@ -194,7 +189,7 @@ function traverseAllChildrenImpl(
189 if (fragment.hasOwnProperty(key)) {
190 child = fragment[key];
191 nextName = (
197 - (nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
192 + nextNamePrefix +
193 wrapUserProvidedKey(key) + SUBSEPARATOR +
194 getComponentKey(child, 0)
195 );