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

Function mapSingleChildIntoContext

code/new-context-api/public/app.js:18557–18576  ·  view source on GitHub ↗
(bookKeeping, child, childKey)

Source from the content-addressed store, hash-verified

18555}
18556
18557function mapSingleChildIntoContext(bookKeeping, child, childKey) {
18558 var result = bookKeeping.result,
18559 keyPrefix = bookKeeping.keyPrefix,
18560 func = bookKeeping.func,
18561 context = bookKeeping.context;
18562
18563
18564 var mappedChild = func.call(context, child, bookKeeping.count++);
18565 if (Array.isArray(mappedChild)) {
18566 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
18567 } else if (mappedChild != null) {
18568 if (isValidElement(mappedChild)) {
18569 mappedChild = cloneAndReplaceKey(mappedChild,
18570 // Keep both the (mapped) and old keys if they differ, just as
18571 // traverseAllChildren used to do for objects as children
18572 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
18573 }
18574 result.push(mappedChild);
18575 }
18576}
18577
18578function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
18579 var escapedPrefix = '';

Callers

nothing calls this directly

Calls 4

isValidElementFunction · 0.70
cloneAndReplaceKeyFunction · 0.70
escapeUserProvidedKeyFunction · 0.70

Tested by

no test coverage detected