(config, stack)
| 11118 | var NO_CONTEXT = {}; |
| 11119 | |
| 11120 | var ReactFiberHostContext = function (config, stack) { |
| 11121 | var getChildHostContext = config.getChildHostContext, |
| 11122 | getRootHostContext = config.getRootHostContext; |
| 11123 | var createCursor = stack.createCursor, |
| 11124 | push = stack.push, |
| 11125 | pop = stack.pop; |
| 11126 | |
| 11127 | |
| 11128 | var contextStackCursor = createCursor(NO_CONTEXT); |
| 11129 | var contextFiberStackCursor = createCursor(NO_CONTEXT); |
| 11130 | var rootInstanceStackCursor = createCursor(NO_CONTEXT); |
| 11131 | |
| 11132 | function requiredContext(c) { |
| 11133 | !(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; |
| 11134 | return c; |
| 11135 | } |
| 11136 | |
| 11137 | function getRootHostContainer() { |
| 11138 | var rootInstance = requiredContext(rootInstanceStackCursor.current); |
| 11139 | return rootInstance; |
| 11140 | } |
| 11141 | |
| 11142 | function pushHostContainer(fiber, nextRootInstance) { |
| 11143 | // Push current root instance onto the stack; |
| 11144 | // This allows us to reset root when portals are popped. |
| 11145 | push(rootInstanceStackCursor, nextRootInstance, fiber); |
| 11146 | |
| 11147 | var nextRootContext = getRootHostContext(nextRootInstance); |
| 11148 | |
| 11149 | // Track the context and the Fiber that provided it. |
| 11150 | // This enables us to pop only Fibers that provide unique contexts. |
| 11151 | push(contextFiberStackCursor, fiber, fiber); |
| 11152 | push(contextStackCursor, nextRootContext, fiber); |
| 11153 | } |
| 11154 | |
| 11155 | function popHostContainer(fiber) { |
| 11156 | pop(contextStackCursor, fiber); |
| 11157 | pop(contextFiberStackCursor, fiber); |
| 11158 | pop(rootInstanceStackCursor, fiber); |
| 11159 | } |
| 11160 | |
| 11161 | function getHostContext() { |
| 11162 | var context = requiredContext(contextStackCursor.current); |
| 11163 | return context; |
| 11164 | } |
| 11165 | |
| 11166 | function pushHostContext(fiber) { |
| 11167 | var rootInstance = requiredContext(rootInstanceStackCursor.current); |
| 11168 | var context = requiredContext(contextStackCursor.current); |
| 11169 | var nextContext = getChildHostContext(context, fiber.type, rootInstance); |
| 11170 | |
| 11171 | // Don't push this Fiber's context unless it's unique. |
| 11172 | if (context === nextContext) { |
| 11173 | return; |
| 11174 | } |
| 11175 | |
| 11176 | // Track the context and the Fiber that provided it. |
| 11177 | // This enables us to pop only Fibers that provide unique contexts. |
no test coverage detected