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

Function mapSingleChildIntoContext

code/styling/public/app.js:19196–19215  ·  view source on GitHub ↗
(bookKeeping, child, childKey)

Source from the content-addressed store, hash-verified

19194}
19195
19196function mapSingleChildIntoContext(bookKeeping, child, childKey) {
19197 var result = bookKeeping.result,
19198 keyPrefix = bookKeeping.keyPrefix,
19199 func = bookKeeping.func,
19200 context = bookKeeping.context;
19201
19202
19203 var mappedChild = func.call(context, child, bookKeeping.count++);
19204 if (Array.isArray(mappedChild)) {
19205 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
19206 } else if (mappedChild != null) {
19207 if (isValidElement(mappedChild)) {
19208 mappedChild = cloneAndReplaceKey(mappedChild,
19209 // Keep both the (mapped) and old keys if they differ, just as
19210 // traverseAllChildren used to do for objects as children
19211 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
19212 }
19213 result.push(mappedChild);
19214 }
19215}
19216
19217function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
19218 var escapedPrefix = '';

Callers

nothing calls this directly

Calls 4

isValidElementFunction · 0.70
cloneAndReplaceKeyFunction · 0.70
escapeUserProvidedKeyFunction · 0.70

Tested by

no test coverage detected