(stack)
| 12417 | } |
| 12418 | |
| 12419 | var ReactFiberLegacyContext = function (stack) { |
| 12420 | var createCursor = stack.createCursor, |
| 12421 | push = stack.push, |
| 12422 | pop = stack.pop; |
| 12423 | |
| 12424 | // A cursor to the current merged context object on the stack. |
| 12425 | |
| 12426 | var contextStackCursor = createCursor(emptyObject); |
| 12427 | // A cursor to a boolean indicating whether the context has changed. |
| 12428 | var didPerformWorkStackCursor = createCursor(false); |
| 12429 | // Keep track of the previous context object that was on the stack. |
| 12430 | // We use this to get access to the parent context after we have already |
| 12431 | // pushed the next context provider, and now need to merge their contexts. |
| 12432 | var previousContext = emptyObject; |
| 12433 | |
| 12434 | function getUnmaskedContext(workInProgress) { |
| 12435 | var hasOwnContext = isContextProvider(workInProgress); |
| 12436 | if (hasOwnContext) { |
| 12437 | // If the fiber is a context provider itself, when we read its context |
| 12438 | // we have already pushed its own child context on the stack. A context |
| 12439 | // provider should not "see" its own child context. Therefore we read the |
| 12440 | // previous (parent) context instead for a context provider. |
| 12441 | return previousContext; |
| 12442 | } |
| 12443 | return contextStackCursor.current; |
| 12444 | } |
| 12445 | |
| 12446 | function cacheContext(workInProgress, unmaskedContext, maskedContext) { |
| 12447 | var instance = workInProgress.stateNode; |
| 12448 | instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; |
| 12449 | instance.__reactInternalMemoizedMaskedChildContext = maskedContext; |
| 12450 | } |
| 12451 | |
| 12452 | function getMaskedContext(workInProgress, unmaskedContext) { |
| 12453 | var type = workInProgress.type; |
| 12454 | var contextTypes = type.contextTypes; |
| 12455 | if (!contextTypes) { |
| 12456 | return emptyObject; |
| 12457 | } |
| 12458 | |
| 12459 | // Avoid recreating masked context unless unmasked context has changed. |
| 12460 | // Failing to do this will result in unnecessary calls to componentWillReceiveProps. |
| 12461 | // This may trigger infinite loops if componentWillReceiveProps calls setState. |
| 12462 | var instance = workInProgress.stateNode; |
| 12463 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { |
| 12464 | return instance.__reactInternalMemoizedMaskedChildContext; |
| 12465 | } |
| 12466 | |
| 12467 | var context = {}; |
| 12468 | for (var key in contextTypes) { |
| 12469 | context[key] = unmaskedContext[key]; |
| 12470 | } |
| 12471 | |
| 12472 | { |
| 12473 | var name = getComponentName(workInProgress) || 'Unknown'; |
| 12474 | checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); |
| 12475 | } |
| 12476 |
no test coverage detected