MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / mapSingleChildIntoContext

Function mapSingleChildIntoContext

code/third-party/public/app.js:18429–18448  ·  view source on GitHub ↗
(bookKeeping, child, childKey)

Source from the content-addressed store, hash-verified

18427}
18428
18429function mapSingleChildIntoContext(bookKeeping, child, childKey) {
18430 var result = bookKeeping.result,
18431 keyPrefix = bookKeeping.keyPrefix,
18432 func = bookKeeping.func,
18433 context = bookKeeping.context;
18434
18435
18436 var mappedChild = func.call(context, child, bookKeeping.count++);
18437 if (Array.isArray(mappedChild)) {
18438 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
18439 } else if (mappedChild != null) {
18440 if (isValidElement(mappedChild)) {
18441 mappedChild = cloneAndReplaceKey(mappedChild,
18442 // Keep both the (mapped) and old keys if they differ, just as
18443 // traverseAllChildren used to do for objects as children
18444 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
18445 }
18446 result.push(mappedChild);
18447 }
18448}
18449
18450function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
18451 var escapedPrefix = '';

Callers

nothing calls this directly

Calls 4

isValidElementFunction · 0.70
cloneAndReplaceKeyFunction · 0.70
escapeUserProvidedKeyFunction · 0.70

Tested by

no test coverage detected