(stack)
| 12314 | } |
| 12315 | |
| 12316 | var ReactFiberLegacyContext = function (stack) { |
| 12317 | var createCursor = stack.createCursor, |
| 12318 | push = stack.push, |
| 12319 | pop = stack.pop; |
| 12320 | |
| 12321 | // A cursor to the current merged context object on the stack. |
| 12322 | |
| 12323 | var contextStackCursor = createCursor(emptyObject); |
| 12324 | // A cursor to a boolean indicating whether the context has changed. |
| 12325 | var didPerformWorkStackCursor = createCursor(false); |
| 12326 | // Keep track of the previous context object that was on the stack. |
| 12327 | // We use this to get access to the parent context after we have already |
| 12328 | // pushed the next context provider, and now need to merge their contexts. |
| 12329 | var previousContext = emptyObject; |
| 12330 | |
| 12331 | function getUnmaskedContext(workInProgress) { |
| 12332 | var hasOwnContext = isContextProvider(workInProgress); |
| 12333 | if (hasOwnContext) { |
| 12334 | // If the fiber is a context provider itself, when we read its context |
| 12335 | // we have already pushed its own child context on the stack. A context |
| 12336 | // provider should not "see" its own child context. Therefore we read the |
| 12337 | // previous (parent) context instead for a context provider. |
| 12338 | return previousContext; |
| 12339 | } |
| 12340 | return contextStackCursor.current; |
| 12341 | } |
| 12342 | |
| 12343 | function cacheContext(workInProgress, unmaskedContext, maskedContext) { |
| 12344 | var instance = workInProgress.stateNode; |
| 12345 | instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; |
| 12346 | instance.__reactInternalMemoizedMaskedChildContext = maskedContext; |
| 12347 | } |
| 12348 | |
| 12349 | function getMaskedContext(workInProgress, unmaskedContext) { |
| 12350 | var type = workInProgress.type; |
| 12351 | var contextTypes = type.contextTypes; |
| 12352 | if (!contextTypes) { |
| 12353 | return emptyObject; |
| 12354 | } |
| 12355 | |
| 12356 | // Avoid recreating masked context unless unmasked context has changed. |
| 12357 | // Failing to do this will result in unnecessary calls to componentWillReceiveProps. |
| 12358 | // This may trigger infinite loops if componentWillReceiveProps calls setState. |
| 12359 | var instance = workInProgress.stateNode; |
| 12360 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { |
| 12361 | return instance.__reactInternalMemoizedMaskedChildContext; |
| 12362 | } |
| 12363 | |
| 12364 | var context = {}; |
| 12365 | for (var key in contextTypes) { |
| 12366 | context[key] = unmaskedContext[key]; |
| 12367 | } |
| 12368 | |
| 12369 | { |
| 12370 | var name = getComponentName(workInProgress) || 'Unknown'; |
| 12371 | checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); |
| 12372 | } |
| 12373 |
no test coverage detected