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

Function mapSingleChildIntoContext

code/communication/public/app.js:19231–19250  ·  view source on GitHub ↗
(bookKeeping, child, childKey)

Source from the content-addressed store, hash-verified

19229}
19230
19231function mapSingleChildIntoContext(bookKeeping, child, childKey) {
19232 var result = bookKeeping.result,
19233 keyPrefix = bookKeeping.keyPrefix,
19234 func = bookKeeping.func,
19235 context = bookKeeping.context;
19236
19237
19238 var mappedChild = func.call(context, child, bookKeeping.count++);
19239 if (Array.isArray(mappedChild)) {
19240 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
19241 } else if (mappedChild != null) {
19242 if (isValidElement(mappedChild)) {
19243 mappedChild = cloneAndReplaceKey(mappedChild,
19244 // Keep both the (mapped) and old keys if they differ, just as
19245 // traverseAllChildren used to do for objects as children
19246 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
19247 }
19248 result.push(mappedChild);
19249 }
19250}
19251
19252function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
19253 var escapedPrefix = '';

Callers

nothing calls this directly

Calls 4

isValidElementFunction · 0.70
cloneAndReplaceKeyFunction · 0.70
escapeUserProvidedKeyFunction · 0.70

Tested by

no test coverage detected