(config, stack)
| 11920 | var NO_CONTEXT = {}; |
| 11921 | |
| 11922 | var ReactFiberHostContext = function (config, stack) { |
| 11923 | var getChildHostContext = config.getChildHostContext, |
| 11924 | getRootHostContext = config.getRootHostContext; |
| 11925 | var createCursor = stack.createCursor, |
| 11926 | push = stack.push, |
| 11927 | pop = stack.pop; |
| 11928 | |
| 11929 | |
| 11930 | var contextStackCursor = createCursor(NO_CONTEXT); |
| 11931 | var contextFiberStackCursor = createCursor(NO_CONTEXT); |
| 11932 | var rootInstanceStackCursor = createCursor(NO_CONTEXT); |
| 11933 | |
| 11934 | function requiredContext(c) { |
| 11935 | !(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; |
| 11936 | return c; |
| 11937 | } |
| 11938 | |
| 11939 | function getRootHostContainer() { |
| 11940 | var rootInstance = requiredContext(rootInstanceStackCursor.current); |
| 11941 | return rootInstance; |
| 11942 | } |
| 11943 | |
| 11944 | function pushHostContainer(fiber, nextRootInstance) { |
| 11945 | // Push current root instance onto the stack; |
| 11946 | // This allows us to reset root when portals are popped. |
| 11947 | push(rootInstanceStackCursor, nextRootInstance, fiber); |
| 11948 | |
| 11949 | var nextRootContext = getRootHostContext(nextRootInstance); |
| 11950 | |
| 11951 | // Track the context and the Fiber that provided it. |
| 11952 | // This enables us to pop only Fibers that provide unique contexts. |
| 11953 | push(contextFiberStackCursor, fiber, fiber); |
| 11954 | push(contextStackCursor, nextRootContext, fiber); |
| 11955 | } |
| 11956 | |
| 11957 | function popHostContainer(fiber) { |
| 11958 | pop(contextStackCursor, fiber); |
| 11959 | pop(contextFiberStackCursor, fiber); |
| 11960 | pop(rootInstanceStackCursor, fiber); |
| 11961 | } |
| 11962 | |
| 11963 | function getHostContext() { |
| 11964 | var context = requiredContext(contextStackCursor.current); |
| 11965 | return context; |
| 11966 | } |
| 11967 | |
| 11968 | function pushHostContext(fiber) { |
| 11969 | var rootInstance = requiredContext(rootInstanceStackCursor.current); |
| 11970 | var context = requiredContext(contextStackCursor.current); |
| 11971 | var nextContext = getChildHostContext(context, fiber.type, rootInstance); |
| 11972 | |
| 11973 | // Don't push this Fiber's context unless it's unique. |
| 11974 | if (context === nextContext) { |
| 11975 | return; |
| 11976 | } |
| 11977 | |
| 11978 | // Track the context and the Fiber that provided it. |
| 11979 | // This enables us to pop only Fibers that provide unique contexts. |
no test coverage detected