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

Function mapSingleChildIntoContext

code/composition/public/app.js:19334–19353  ·  view source on GitHub ↗
(bookKeeping, child, childKey)

Source from the content-addressed store, hash-verified

19332}
19333
19334function mapSingleChildIntoContext(bookKeeping, child, childKey) {
19335 var result = bookKeeping.result,
19336 keyPrefix = bookKeeping.keyPrefix,
19337 func = bookKeeping.func,
19338 context = bookKeeping.context;
19339
19340
19341 var mappedChild = func.call(context, child, bookKeeping.count++);
19342 if (Array.isArray(mappedChild)) {
19343 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
19344 } else if (mappedChild != null) {
19345 if (isValidElement(mappedChild)) {
19346 mappedChild = cloneAndReplaceKey(mappedChild,
19347 // Keep both the (mapped) and old keys if they differ, just as
19348 // traverseAllChildren used to do for objects as children
19349 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
19350 }
19351 result.push(mappedChild);
19352 }
19353}
19354
19355function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
19356 var escapedPrefix = '';

Callers

nothing calls this directly

Calls 4

isValidElementFunction · 0.70
cloneAndReplaceKeyFunction · 0.70
escapeUserProvidedKeyFunction · 0.70

Tested by

no test coverage detected