(config, stack)
| 11246 | var NO_CONTEXT = {}; |
| 11247 | |
| 11248 | var ReactFiberHostContext = function (config, stack) { |
| 11249 | var getChildHostContext = config.getChildHostContext, |
| 11250 | getRootHostContext = config.getRootHostContext; |
| 11251 | var createCursor = stack.createCursor, |
| 11252 | push = stack.push, |
| 11253 | pop = stack.pop; |
| 11254 | |
| 11255 | |
| 11256 | var contextStackCursor = createCursor(NO_CONTEXT); |
| 11257 | var contextFiberStackCursor = createCursor(NO_CONTEXT); |
| 11258 | var rootInstanceStackCursor = createCursor(NO_CONTEXT); |
| 11259 | |
| 11260 | function requiredContext(c) { |
| 11261 | !(c !== NO_CONTEXT) ? invariant(false, 'Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.') : void 0; |
| 11262 | return c; |
| 11263 | } |
| 11264 | |
| 11265 | function getRootHostContainer() { |
| 11266 | var rootInstance = requiredContext(rootInstanceStackCursor.current); |
| 11267 | return rootInstance; |
| 11268 | } |
| 11269 | |
| 11270 | function pushHostContainer(fiber, nextRootInstance) { |
| 11271 | // Push current root instance onto the stack; |
| 11272 | // This allows us to reset root when portals are popped. |
| 11273 | push(rootInstanceStackCursor, nextRootInstance, fiber); |
| 11274 | |
| 11275 | var nextRootContext = getRootHostContext(nextRootInstance); |
| 11276 | |
| 11277 | // Track the context and the Fiber that provided it. |
| 11278 | // This enables us to pop only Fibers that provide unique contexts. |
| 11279 | push(contextFiberStackCursor, fiber, fiber); |
| 11280 | push(contextStackCursor, nextRootContext, fiber); |
| 11281 | } |
| 11282 | |
| 11283 | function popHostContainer(fiber) { |
| 11284 | pop(contextStackCursor, fiber); |
| 11285 | pop(contextFiberStackCursor, fiber); |
| 11286 | pop(rootInstanceStackCursor, fiber); |
| 11287 | } |
| 11288 | |
| 11289 | function getHostContext() { |
| 11290 | var context = requiredContext(contextStackCursor.current); |
| 11291 | return context; |
| 11292 | } |
| 11293 | |
| 11294 | function pushHostContext(fiber) { |
| 11295 | var rootInstance = requiredContext(rootInstanceStackCursor.current); |
| 11296 | var context = requiredContext(contextStackCursor.current); |
| 11297 | var nextContext = getChildHostContext(context, fiber.type, rootInstance); |
| 11298 | |
| 11299 | // Don't push this Fiber's context unless it's unique. |
| 11300 | if (context === nextContext) { |
| 11301 | return; |
| 11302 | } |
| 11303 | |
| 11304 | // Track the context and the Fiber that provided it. |
| 11305 | // This enables us to pop only Fibers that provide unique contexts. |
no test coverage detected