(config, stack)
| 11885 | var NO_CONTEXT = {}; |
| 11886 | |
| 11887 | var ReactFiberHostContext = function (config, stack) { |
| 11888 | var getChildHostContext = config.getChildHostContext, |
| 11889 | getRootHostContext = config.getRootHostContext; |
| 11890 | var createCursor = stack.createCursor, |
| 11891 | push = stack.push, |
| 11892 | pop = stack.pop; |
| 11893 | |
| 11894 | |
| 11895 | var contextStackCursor = createCursor(NO_CONTEXT); |
| 11896 | var contextFiberStackCursor = createCursor(NO_CONTEXT); |
| 11897 | var rootInstanceStackCursor = createCursor(NO_CONTEXT); |
| 11898 | |
| 11899 | function requiredContext(c) { |
| 11900 | !(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; |
| 11901 | return c; |
| 11902 | } |
| 11903 | |
| 11904 | function getRootHostContainer() { |
| 11905 | var rootInstance = requiredContext(rootInstanceStackCursor.current); |
| 11906 | return rootInstance; |
| 11907 | } |
| 11908 | |
| 11909 | function pushHostContainer(fiber, nextRootInstance) { |
| 11910 | // Push current root instance onto the stack; |
| 11911 | // This allows us to reset root when portals are popped. |
| 11912 | push(rootInstanceStackCursor, nextRootInstance, fiber); |
| 11913 | |
| 11914 | var nextRootContext = getRootHostContext(nextRootInstance); |
| 11915 | |
| 11916 | // Track the context and the Fiber that provided it. |
| 11917 | // This enables us to pop only Fibers that provide unique contexts. |
| 11918 | push(contextFiberStackCursor, fiber, fiber); |
| 11919 | push(contextStackCursor, nextRootContext, fiber); |
| 11920 | } |
| 11921 | |
| 11922 | function popHostContainer(fiber) { |
| 11923 | pop(contextStackCursor, fiber); |
| 11924 | pop(contextFiberStackCursor, fiber); |
| 11925 | pop(rootInstanceStackCursor, fiber); |
| 11926 | } |
| 11927 | |
| 11928 | function getHostContext() { |
| 11929 | var context = requiredContext(contextStackCursor.current); |
| 11930 | return context; |
| 11931 | } |
| 11932 | |
| 11933 | function pushHostContext(fiber) { |
| 11934 | var rootInstance = requiredContext(rootInstanceStackCursor.current); |
| 11935 | var context = requiredContext(contextStackCursor.current); |
| 11936 | var nextContext = getChildHostContext(context, fiber.type, rootInstance); |
| 11937 | |
| 11938 | // Don't push this Fiber's context unless it's unique. |
| 11939 | if (context === nextContext) { |
| 11940 | return; |
| 11941 | } |
| 11942 | |
| 11943 | // Track the context and the Fiber that provided it. |
| 11944 | // This enables us to pop only Fibers that provide unique contexts. |
no test coverage detected