(stack)
| 12279 | } |
| 12280 | |
| 12281 | var ReactFiberLegacyContext = function (stack) { |
| 12282 | var createCursor = stack.createCursor, |
| 12283 | push = stack.push, |
| 12284 | pop = stack.pop; |
| 12285 | |
| 12286 | // A cursor to the current merged context object on the stack. |
| 12287 | |
| 12288 | var contextStackCursor = createCursor(emptyObject); |
| 12289 | // A cursor to a boolean indicating whether the context has changed. |
| 12290 | var didPerformWorkStackCursor = createCursor(false); |
| 12291 | // Keep track of the previous context object that was on the stack. |
| 12292 | // We use this to get access to the parent context after we have already |
| 12293 | // pushed the next context provider, and now need to merge their contexts. |
| 12294 | var previousContext = emptyObject; |
| 12295 | |
| 12296 | function getUnmaskedContext(workInProgress) { |
| 12297 | var hasOwnContext = isContextProvider(workInProgress); |
| 12298 | if (hasOwnContext) { |
| 12299 | // If the fiber is a context provider itself, when we read its context |
| 12300 | // we have already pushed its own child context on the stack. A context |
| 12301 | // provider should not "see" its own child context. Therefore we read the |
| 12302 | // previous (parent) context instead for a context provider. |
| 12303 | return previousContext; |
| 12304 | } |
| 12305 | return contextStackCursor.current; |
| 12306 | } |
| 12307 | |
| 12308 | function cacheContext(workInProgress, unmaskedContext, maskedContext) { |
| 12309 | var instance = workInProgress.stateNode; |
| 12310 | instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; |
| 12311 | instance.__reactInternalMemoizedMaskedChildContext = maskedContext; |
| 12312 | } |
| 12313 | |
| 12314 | function getMaskedContext(workInProgress, unmaskedContext) { |
| 12315 | var type = workInProgress.type; |
| 12316 | var contextTypes = type.contextTypes; |
| 12317 | if (!contextTypes) { |
| 12318 | return emptyObject; |
| 12319 | } |
| 12320 | |
| 12321 | // Avoid recreating masked context unless unmasked context has changed. |
| 12322 | // Failing to do this will result in unnecessary calls to componentWillReceiveProps. |
| 12323 | // This may trigger infinite loops if componentWillReceiveProps calls setState. |
| 12324 | var instance = workInProgress.stateNode; |
| 12325 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { |
| 12326 | return instance.__reactInternalMemoizedMaskedChildContext; |
| 12327 | } |
| 12328 | |
| 12329 | var context = {}; |
| 12330 | for (var key in contextTypes) { |
| 12331 | context[key] = unmaskedContext[key]; |
| 12332 | } |
| 12333 | |
| 12334 | { |
| 12335 | var name = getComponentName(workInProgress) || 'Unknown'; |
| 12336 | checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); |
| 12337 | } |
| 12338 |
no test coverage detected