MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / mapSingleChildIntoContext

Function mapSingleChildIntoContext

examples/simple/react.js:4272–4290  ·  view source on GitHub ↗
(bookKeeping, child, childKey)

Source from the content-addressed store, hash-verified

4270PooledClass.addPoolingTo(MapBookKeeping, fourArgumentPooler);
4271
4272function mapSingleChildIntoContext(bookKeeping, child, childKey) {
4273 var result = bookKeeping.result;
4274 var keyPrefix = bookKeeping.keyPrefix;
4275 var func = bookKeeping.func;
4276 var context = bookKeeping.context;
4277
4278 var mappedChild = func.call(context, child, bookKeeping.count++);
4279 if (Array.isArray(mappedChild)) {
4280 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
4281 } else if (mappedChild != null) {
4282 if (ReactElement.isValidElement(mappedChild)) {
4283 mappedChild = ReactElement.cloneAndReplaceKey(mappedChild,
4284 // Keep both the (mapped) and old keys if they differ, just as
4285 // traverseAllChildren used to do for objects as children
4286 keyPrefix + (mappedChild !== child ? escapeUserProvidedKey(mappedChild.key || '') + '/' : '') + childKey);
4287 }
4288 result.push(mappedChild);
4289 }
4290}
4291
4292function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
4293 var escapedPrefix = '';

Callers

nothing calls this directly

Calls 2

escapeUserProvidedKeyFunction · 0.70

Tested by

no test coverage detected