MCPcopy Create free account
hub / github.com/microsoft/SandDance / mapSingleChildIntoContext

Function mapSingleChildIntoContext

docs/external/js/react.development.js:1230–1250  ·  view source on GitHub ↗
(bookKeeping, child, childKey)

Source from the content-addressed store, hash-verified

1228 }
1229
1230 function mapSingleChildIntoContext(bookKeeping, child, childKey) {
1231 var result = bookKeeping.result,
1232 keyPrefix = bookKeeping.keyPrefix,
1233 func = bookKeeping.func,
1234 context = bookKeeping.context;
1235 var mappedChild = func.call(context, child, bookKeeping.count++);
1236
1237 if (Array.isArray(mappedChild)) {
1238 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
1239 return c;
1240 });
1241 } else if (mappedChild != null) {
1242 if (isValidElement(mappedChild)) {
1243 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
1244 // traverseAllChildren used to do for objects as children
1245 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
1246 }
1247
1248 result.push(mappedChild);
1249 }
1250 }
1251
1252 function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
1253 var escapedPrefix = '';

Callers

nothing calls this directly

Calls 4

isValidElementFunction · 0.85
cloneAndReplaceKeyFunction · 0.85
escapeUserProvidedKeyFunction · 0.85

Tested by

no test coverage detected