React sync for revisions ced176e...9d484ed
Reviewed By: bvaughn Differential Revision: D7338640 fbshipit-source-id: e2d75d2f1795fb3c37f193d15216951c707711d9
This commit is contained in:
parent
73ffa6003a
commit
69c77d6492
|
@ -1 +1 @@
|
||||||
ced176edb7605a25e916895fd060f3943c647fee
|
9d484edc4b64160cb335a23a2cb21667fb2cdf4c
|
File diff suppressed because it is too large
Load Diff
|
@ -1633,136 +1633,6 @@ function findCurrentHostFiberWithNoPortals(parent) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var valueStack = [],
|
|
||||||
index = -1;
|
|
||||||
function pop(cursor) {
|
|
||||||
0 > index ||
|
|
||||||
((cursor.current = valueStack[index]), (valueStack[index] = null), index--);
|
|
||||||
}
|
|
||||||
function push(cursor, value) {
|
|
||||||
index++;
|
|
||||||
valueStack[index] = cursor.current;
|
|
||||||
cursor.current = value;
|
|
||||||
}
|
|
||||||
function getStackAddendumByWorkInProgressFiber(workInProgress) {
|
|
||||||
var info = "";
|
|
||||||
do {
|
|
||||||
a: switch (workInProgress.tag) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 5:
|
|
||||||
var owner = workInProgress._debugOwner,
|
|
||||||
source = workInProgress._debugSource;
|
|
||||||
var JSCompiler_inline_result = getComponentName(workInProgress);
|
|
||||||
var ownerName = null;
|
|
||||||
owner && (ownerName = getComponentName(owner));
|
|
||||||
owner = source;
|
|
||||||
JSCompiler_inline_result =
|
|
||||||
"\n in " +
|
|
||||||
(JSCompiler_inline_result || "Unknown") +
|
|
||||||
(owner
|
|
||||||
? " (at " +
|
|
||||||
owner.fileName.replace(/^.*[\\\/]/, "") +
|
|
||||||
":" +
|
|
||||||
owner.lineNumber +
|
|
||||||
")"
|
|
||||||
: ownerName ? " (created by " + ownerName + ")" : "");
|
|
||||||
break a;
|
|
||||||
default:
|
|
||||||
JSCompiler_inline_result = "";
|
|
||||||
}
|
|
||||||
info += JSCompiler_inline_result;
|
|
||||||
workInProgress = workInProgress["return"];
|
|
||||||
} while (workInProgress);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
new Set();
|
|
||||||
var contextStackCursor = { current: emptyObject },
|
|
||||||
didPerformWorkStackCursor = { current: !1 },
|
|
||||||
previousContext = emptyObject;
|
|
||||||
function getUnmaskedContext(workInProgress) {
|
|
||||||
return isContextProvider(workInProgress)
|
|
||||||
? previousContext
|
|
||||||
: contextStackCursor.current;
|
|
||||||
}
|
|
||||||
function getMaskedContext(workInProgress, unmaskedContext) {
|
|
||||||
var contextTypes = workInProgress.type.contextTypes;
|
|
||||||
if (!contextTypes) return emptyObject;
|
|
||||||
var instance = workInProgress.stateNode;
|
|
||||||
if (
|
|
||||||
instance &&
|
|
||||||
instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext
|
|
||||||
)
|
|
||||||
return instance.__reactInternalMemoizedMaskedChildContext;
|
|
||||||
var context = {},
|
|
||||||
key;
|
|
||||||
for (key in contextTypes) context[key] = unmaskedContext[key];
|
|
||||||
instance &&
|
|
||||||
((workInProgress = workInProgress.stateNode),
|
|
||||||
(workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext),
|
|
||||||
(workInProgress.__reactInternalMemoizedMaskedChildContext = context));
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
function isContextProvider(fiber) {
|
|
||||||
return 2 === fiber.tag && null != fiber.type.childContextTypes;
|
|
||||||
}
|
|
||||||
function popContextProvider(fiber) {
|
|
||||||
isContextProvider(fiber) &&
|
|
||||||
(pop(didPerformWorkStackCursor, fiber), pop(contextStackCursor, fiber));
|
|
||||||
}
|
|
||||||
function pushTopLevelContextObject(fiber, context, didChange) {
|
|
||||||
invariant(
|
|
||||||
null == contextStackCursor.cursor,
|
|
||||||
"Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."
|
|
||||||
);
|
|
||||||
push(contextStackCursor, context, fiber);
|
|
||||||
push(didPerformWorkStackCursor, didChange, fiber);
|
|
||||||
}
|
|
||||||
function processChildContext(fiber, parentContext) {
|
|
||||||
var instance = fiber.stateNode,
|
|
||||||
childContextTypes = fiber.type.childContextTypes;
|
|
||||||
if ("function" !== typeof instance.getChildContext) return parentContext;
|
|
||||||
instance = instance.getChildContext();
|
|
||||||
for (var contextKey in instance)
|
|
||||||
invariant(
|
|
||||||
contextKey in childContextTypes,
|
|
||||||
'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
|
|
||||||
getComponentName(fiber) || "Unknown",
|
|
||||||
contextKey
|
|
||||||
);
|
|
||||||
return Object.assign({}, parentContext, instance);
|
|
||||||
}
|
|
||||||
function pushContextProvider(workInProgress) {
|
|
||||||
if (!isContextProvider(workInProgress)) return !1;
|
|
||||||
var instance = workInProgress.stateNode;
|
|
||||||
instance =
|
|
||||||
(instance && instance.__reactInternalMemoizedMergedChildContext) ||
|
|
||||||
emptyObject;
|
|
||||||
previousContext = contextStackCursor.current;
|
|
||||||
push(contextStackCursor, instance, workInProgress);
|
|
||||||
push(
|
|
||||||
didPerformWorkStackCursor,
|
|
||||||
didPerformWorkStackCursor.current,
|
|
||||||
workInProgress
|
|
||||||
);
|
|
||||||
return !0;
|
|
||||||
}
|
|
||||||
function invalidateContextProvider(workInProgress, didChange) {
|
|
||||||
var instance = workInProgress.stateNode;
|
|
||||||
invariant(
|
|
||||||
instance,
|
|
||||||
"Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."
|
|
||||||
);
|
|
||||||
if (didChange) {
|
|
||||||
var mergedContext = processChildContext(workInProgress, previousContext);
|
|
||||||
instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
|
||||||
pop(didPerformWorkStackCursor, workInProgress);
|
|
||||||
pop(contextStackCursor, workInProgress);
|
|
||||||
push(contextStackCursor, mergedContext, workInProgress);
|
|
||||||
} else pop(didPerformWorkStackCursor, workInProgress);
|
|
||||||
push(didPerformWorkStackCursor, didChange, workInProgress);
|
|
||||||
}
|
|
||||||
function FiberNode(tag, pendingProps, key, mode) {
|
function FiberNode(tag, pendingProps, key, mode) {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
@ -1929,6 +1799,40 @@ function onCommitRoot(root) {
|
||||||
function onCommitUnmount(fiber) {
|
function onCommitUnmount(fiber) {
|
||||||
"function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(fiber);
|
"function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(fiber);
|
||||||
}
|
}
|
||||||
|
function getStackAddendumByWorkInProgressFiber(workInProgress) {
|
||||||
|
var info = "";
|
||||||
|
do {
|
||||||
|
a: switch (workInProgress.tag) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 5:
|
||||||
|
var owner = workInProgress._debugOwner,
|
||||||
|
source = workInProgress._debugSource;
|
||||||
|
var JSCompiler_inline_result = getComponentName(workInProgress);
|
||||||
|
var ownerName = null;
|
||||||
|
owner && (ownerName = getComponentName(owner));
|
||||||
|
owner = source;
|
||||||
|
JSCompiler_inline_result =
|
||||||
|
"\n in " +
|
||||||
|
(JSCompiler_inline_result || "Unknown") +
|
||||||
|
(owner
|
||||||
|
? " (at " +
|
||||||
|
owner.fileName.replace(/^.*[\\\/]/, "") +
|
||||||
|
":" +
|
||||||
|
owner.lineNumber +
|
||||||
|
")"
|
||||||
|
: ownerName ? " (created by " + ownerName + ")" : "");
|
||||||
|
break a;
|
||||||
|
default:
|
||||||
|
JSCompiler_inline_result = "";
|
||||||
|
}
|
||||||
|
info += JSCompiler_inline_result;
|
||||||
|
workInProgress = workInProgress["return"];
|
||||||
|
} while (workInProgress);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
new Set();
|
||||||
function createUpdateQueue(baseState) {
|
function createUpdateQueue(baseState) {
|
||||||
return {
|
return {
|
||||||
baseState: baseState,
|
baseState: baseState,
|
||||||
|
@ -2084,6 +1988,7 @@ function commitCallbacks(queue, context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function ReactFiberClassComponent(
|
function ReactFiberClassComponent(
|
||||||
|
legacyContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
computeExpirationForFiber,
|
computeExpirationForFiber,
|
||||||
memoizeProps,
|
memoizeProps,
|
||||||
|
@ -2140,62 +2045,66 @@ function ReactFiberClassComponent(
|
||||||
workInProgress.memoizedState
|
workInProgress.memoizedState
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var updater = {
|
var cacheContext = legacyContext.cacheContext,
|
||||||
isMounted: isMounted,
|
getMaskedContext = legacyContext.getMaskedContext,
|
||||||
enqueueSetState: function(instance, partialState, callback) {
|
getUnmaskedContext = legacyContext.getUnmaskedContext,
|
||||||
instance = instance._reactInternalFiber;
|
isContextConsumer = legacyContext.isContextConsumer,
|
||||||
callback = void 0 === callback ? null : callback;
|
hasContextChanged = legacyContext.hasContextChanged,
|
||||||
var expirationTime = computeExpirationForFiber(instance);
|
updater = {
|
||||||
insertUpdateIntoFiber(instance, {
|
isMounted: isMounted,
|
||||||
expirationTime: expirationTime,
|
enqueueSetState: function(instance, partialState, callback) {
|
||||||
partialState: partialState,
|
instance = instance._reactInternalFiber;
|
||||||
callback: callback,
|
callback = void 0 === callback ? null : callback;
|
||||||
isReplace: !1,
|
var expirationTime = computeExpirationForFiber(instance);
|
||||||
isForced: !1,
|
insertUpdateIntoFiber(instance, {
|
||||||
capturedValue: null,
|
expirationTime: expirationTime,
|
||||||
next: null
|
partialState: partialState,
|
||||||
});
|
callback: callback,
|
||||||
scheduleWork(instance, expirationTime);
|
isReplace: !1,
|
||||||
},
|
isForced: !1,
|
||||||
enqueueReplaceState: function(instance, state, callback) {
|
capturedValue: null,
|
||||||
instance = instance._reactInternalFiber;
|
next: null
|
||||||
callback = void 0 === callback ? null : callback;
|
});
|
||||||
var expirationTime = computeExpirationForFiber(instance);
|
scheduleWork(instance, expirationTime);
|
||||||
insertUpdateIntoFiber(instance, {
|
},
|
||||||
expirationTime: expirationTime,
|
enqueueReplaceState: function(instance, state, callback) {
|
||||||
partialState: state,
|
instance = instance._reactInternalFiber;
|
||||||
callback: callback,
|
callback = void 0 === callback ? null : callback;
|
||||||
isReplace: !0,
|
var expirationTime = computeExpirationForFiber(instance);
|
||||||
isForced: !1,
|
insertUpdateIntoFiber(instance, {
|
||||||
capturedValue: null,
|
expirationTime: expirationTime,
|
||||||
next: null
|
partialState: state,
|
||||||
});
|
callback: callback,
|
||||||
scheduleWork(instance, expirationTime);
|
isReplace: !0,
|
||||||
},
|
isForced: !1,
|
||||||
enqueueForceUpdate: function(instance, callback) {
|
capturedValue: null,
|
||||||
instance = instance._reactInternalFiber;
|
next: null
|
||||||
callback = void 0 === callback ? null : callback;
|
});
|
||||||
var expirationTime = computeExpirationForFiber(instance);
|
scheduleWork(instance, expirationTime);
|
||||||
insertUpdateIntoFiber(instance, {
|
},
|
||||||
expirationTime: expirationTime,
|
enqueueForceUpdate: function(instance, callback) {
|
||||||
partialState: null,
|
instance = instance._reactInternalFiber;
|
||||||
callback: callback,
|
callback = void 0 === callback ? null : callback;
|
||||||
isReplace: !1,
|
var expirationTime = computeExpirationForFiber(instance);
|
||||||
isForced: !0,
|
insertUpdateIntoFiber(instance, {
|
||||||
capturedValue: null,
|
expirationTime: expirationTime,
|
||||||
next: null
|
partialState: null,
|
||||||
});
|
callback: callback,
|
||||||
scheduleWork(instance, expirationTime);
|
isReplace: !1,
|
||||||
}
|
isForced: !0,
|
||||||
};
|
capturedValue: null,
|
||||||
|
next: null
|
||||||
|
});
|
||||||
|
scheduleWork(instance, expirationTime);
|
||||||
|
}
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
adoptClassInstance: adoptClassInstance,
|
adoptClassInstance: adoptClassInstance,
|
||||||
callGetDerivedStateFromProps: callGetDerivedStateFromProps,
|
callGetDerivedStateFromProps: callGetDerivedStateFromProps,
|
||||||
constructClassInstance: function(workInProgress, props) {
|
constructClassInstance: function(workInProgress, props) {
|
||||||
var ctor = workInProgress.type,
|
var ctor = workInProgress.type,
|
||||||
unmaskedContext = getUnmaskedContext(workInProgress),
|
unmaskedContext = getUnmaskedContext(workInProgress),
|
||||||
needsContext =
|
needsContext = isContextConsumer(workInProgress),
|
||||||
2 === workInProgress.tag && null != workInProgress.type.contextTypes,
|
|
||||||
context = needsContext
|
context = needsContext
|
||||||
? getMaskedContext(workInProgress, unmaskedContext)
|
? getMaskedContext(workInProgress, unmaskedContext)
|
||||||
: emptyObject;
|
: emptyObject;
|
||||||
|
@ -2212,10 +2121,7 @@ function ReactFiberClassComponent(
|
||||||
workInProgress.memoizedState,
|
workInProgress.memoizedState,
|
||||||
props
|
props
|
||||||
));
|
));
|
||||||
needsContext &&
|
needsContext && cacheContext(workInProgress, unmaskedContext, context);
|
||||||
((workInProgress = workInProgress.stateNode),
|
|
||||||
(workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext),
|
|
||||||
(workInProgress.__reactInternalMemoizedMaskedChildContext = context));
|
|
||||||
return ctor;
|
return ctor;
|
||||||
},
|
},
|
||||||
mountClassInstance: function(workInProgress, renderExpirationTime) {
|
mountClassInstance: function(workInProgress, renderExpirationTime) {
|
||||||
|
@ -2300,7 +2206,7 @@ function ReactFiberClassComponent(
|
||||||
!(
|
!(
|
||||||
oldProps !== newProps ||
|
oldProps !== newProps ||
|
||||||
oldState !== renderExpirationTime ||
|
oldState !== renderExpirationTime ||
|
||||||
didPerformWorkStackCursor.current ||
|
hasContextChanged() ||
|
||||||
(null !== workInProgress.updateQueue &&
|
(null !== workInProgress.updateQueue &&
|
||||||
workInProgress.updateQueue.hasForceUpdate)
|
workInProgress.updateQueue.hasForceUpdate)
|
||||||
)
|
)
|
||||||
|
@ -2389,7 +2295,7 @@ function ReactFiberClassComponent(
|
||||||
!(
|
!(
|
||||||
oldProps !== newProps ||
|
oldProps !== newProps ||
|
||||||
oldContext !== renderExpirationTime ||
|
oldContext !== renderExpirationTime ||
|
||||||
didPerformWorkStackCursor.current ||
|
hasContextChanged() ||
|
||||||
(null !== workInProgress.updateQueue &&
|
(null !== workInProgress.updateQueue &&
|
||||||
workInProgress.updateQueue.hasForceUpdate)
|
workInProgress.updateQueue.hasForceUpdate)
|
||||||
)
|
)
|
||||||
|
@ -3112,34 +3018,12 @@ function ChildReconciler(shouldTrackSideEffects) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var reconcileChildFibers = ChildReconciler(!0),
|
var reconcileChildFibers = ChildReconciler(!0),
|
||||||
mountChildFibers = ChildReconciler(!1),
|
mountChildFibers = ChildReconciler(!1);
|
||||||
changedBitsStack = [],
|
|
||||||
currentValueStack = [],
|
|
||||||
stack = [],
|
|
||||||
index$1 = -1;
|
|
||||||
function pushProvider(providerFiber) {
|
|
||||||
var context = providerFiber.type.context;
|
|
||||||
index$1 += 1;
|
|
||||||
changedBitsStack[index$1] = context._changedBits;
|
|
||||||
currentValueStack[index$1] = context._currentValue;
|
|
||||||
stack[index$1] = providerFiber;
|
|
||||||
context._currentValue = providerFiber.pendingProps.value;
|
|
||||||
context._changedBits = providerFiber.stateNode;
|
|
||||||
}
|
|
||||||
function popProvider(providerFiber) {
|
|
||||||
var changedBits = changedBitsStack[index$1],
|
|
||||||
currentValue = currentValueStack[index$1];
|
|
||||||
changedBitsStack[index$1] = null;
|
|
||||||
currentValueStack[index$1] = null;
|
|
||||||
stack[index$1] = null;
|
|
||||||
--index$1;
|
|
||||||
providerFiber = providerFiber.type.context;
|
|
||||||
providerFiber._currentValue = currentValue;
|
|
||||||
providerFiber._changedBits = changedBits;
|
|
||||||
}
|
|
||||||
function ReactFiberBeginWork(
|
function ReactFiberBeginWork(
|
||||||
config,
|
config,
|
||||||
hostContext,
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
newContext,
|
||||||
hydrationContext,
|
hydrationContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
computeExpirationForFiber
|
computeExpirationForFiber
|
||||||
|
@ -3236,7 +3120,12 @@ function ReactFiberBeginWork(
|
||||||
changedBits,
|
changedBits,
|
||||||
renderExpirationTime
|
renderExpirationTime
|
||||||
) {
|
) {
|
||||||
for (var fiber = workInProgress.child; null !== fiber; ) {
|
var fiber = workInProgress.child;
|
||||||
|
for (
|
||||||
|
null !== fiber && (fiber["return"] = workInProgress);
|
||||||
|
null !== fiber;
|
||||||
|
|
||||||
|
) {
|
||||||
switch (fiber.tag) {
|
switch (fiber.tag) {
|
||||||
case 12:
|
case 12:
|
||||||
var nextFiber = fiber.stateNode | 0;
|
var nextFiber = fiber.stateNode | 0;
|
||||||
|
@ -3295,7 +3184,7 @@ function ReactFiberBeginWork(
|
||||||
var context = workInProgress.type.context,
|
var context = workInProgress.type.context,
|
||||||
newProps = workInProgress.pendingProps,
|
newProps = workInProgress.pendingProps,
|
||||||
oldProps = workInProgress.memoizedProps;
|
oldProps = workInProgress.memoizedProps;
|
||||||
if (!didPerformWorkStackCursor.current && oldProps === newProps)
|
if (!hasLegacyContextChanged() && oldProps === newProps)
|
||||||
return (
|
return (
|
||||||
(workInProgress.stateNode = 0),
|
(workInProgress.stateNode = 0),
|
||||||
pushProvider(workInProgress),
|
pushProvider(workInProgress),
|
||||||
|
@ -3382,11 +3271,19 @@ function ReactFiberBeginWork(
|
||||||
shouldDeprioritizeSubtree = config.shouldDeprioritizeSubtree,
|
shouldDeprioritizeSubtree = config.shouldDeprioritizeSubtree,
|
||||||
pushHostContext = hostContext.pushHostContext,
|
pushHostContext = hostContext.pushHostContext,
|
||||||
pushHostContainer = hostContext.pushHostContainer,
|
pushHostContainer = hostContext.pushHostContainer,
|
||||||
|
pushProvider = newContext.pushProvider,
|
||||||
|
getMaskedContext = legacyContext.getMaskedContext,
|
||||||
|
getUnmaskedContext = legacyContext.getUnmaskedContext,
|
||||||
|
hasLegacyContextChanged = legacyContext.hasContextChanged,
|
||||||
|
pushLegacyContextProvider = legacyContext.pushContextProvider,
|
||||||
|
pushTopLevelContextObject = legacyContext.pushTopLevelContextObject,
|
||||||
|
invalidateContextProvider = legacyContext.invalidateContextProvider,
|
||||||
enterHydrationState = hydrationContext.enterHydrationState,
|
enterHydrationState = hydrationContext.enterHydrationState,
|
||||||
resetHydrationState = hydrationContext.resetHydrationState,
|
resetHydrationState = hydrationContext.resetHydrationState,
|
||||||
tryToClaimNextHydratableInstance =
|
tryToClaimNextHydratableInstance =
|
||||||
hydrationContext.tryToClaimNextHydratableInstance;
|
hydrationContext.tryToClaimNextHydratableInstance;
|
||||||
config = ReactFiberClassComponent(
|
config = ReactFiberClassComponent(
|
||||||
|
legacyContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
computeExpirationForFiber,
|
computeExpirationForFiber,
|
||||||
function(workInProgress, nextProps) {
|
function(workInProgress, nextProps) {
|
||||||
|
@ -3413,7 +3310,7 @@ function ReactFiberBeginWork(
|
||||||
pushHostRootContext(workInProgress);
|
pushHostRootContext(workInProgress);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
pushContextProvider(workInProgress);
|
pushLegacyContextProvider(workInProgress);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
pushHostContainer(
|
pushHostContainer(
|
||||||
|
@ -3459,7 +3356,7 @@ function ReactFiberBeginWork(
|
||||||
workInProgress.memoizedState,
|
workInProgress.memoizedState,
|
||||||
props
|
props
|
||||||
))),
|
))),
|
||||||
(props = pushContextProvider(workInProgress)),
|
(props = pushLegacyContextProvider(workInProgress)),
|
||||||
adoptClassInstance(workInProgress, fn),
|
adoptClassInstance(workInProgress, fn),
|
||||||
mountClassInstance(workInProgress, renderExpirationTime),
|
mountClassInstance(workInProgress, renderExpirationTime),
|
||||||
(current = finishClassComponent(
|
(current = finishClassComponent(
|
||||||
|
@ -3479,7 +3376,7 @@ function ReactFiberBeginWork(
|
||||||
return (
|
return (
|
||||||
(props = workInProgress.type),
|
(props = workInProgress.type),
|
||||||
(renderExpirationTime = workInProgress.pendingProps),
|
(renderExpirationTime = workInProgress.pendingProps),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
workInProgress.memoizedProps !== renderExpirationTime
|
workInProgress.memoizedProps !== renderExpirationTime
|
||||||
? ((fn = getUnmaskedContext(workInProgress)),
|
? ((fn = getUnmaskedContext(workInProgress)),
|
||||||
(fn = getMaskedContext(workInProgress, fn)),
|
(fn = getMaskedContext(workInProgress, fn)),
|
||||||
|
@ -3495,7 +3392,7 @@ function ReactFiberBeginWork(
|
||||||
current
|
current
|
||||||
);
|
);
|
||||||
case 2:
|
case 2:
|
||||||
props = pushContextProvider(workInProgress);
|
props = pushLegacyContextProvider(workInProgress);
|
||||||
null === current
|
null === current
|
||||||
? null === workInProgress.stateNode
|
? null === workInProgress.stateNode
|
||||||
? (constructClassInstance(
|
? (constructClassInstance(
|
||||||
|
@ -3577,7 +3474,7 @@ function ReactFiberBeginWork(
|
||||||
updateQueue = workInProgress.memoizedProps;
|
updateQueue = workInProgress.memoizedProps;
|
||||||
fn = workInProgress.pendingProps;
|
fn = workInProgress.pendingProps;
|
||||||
unmaskedContext = null !== current ? current.memoizedProps : null;
|
unmaskedContext = null !== current ? current.memoizedProps : null;
|
||||||
if (!didPerformWorkStackCursor.current && updateQueue === fn) {
|
if (!hasLegacyContextChanged() && updateQueue === fn) {
|
||||||
if (
|
if (
|
||||||
(updateQueue =
|
(updateQueue =
|
||||||
workInProgress.mode & 1 &&
|
workInProgress.mode & 1 &&
|
||||||
|
@ -3619,7 +3516,7 @@ function ReactFiberBeginWork(
|
||||||
case 7:
|
case 7:
|
||||||
return (
|
return (
|
||||||
(props = workInProgress.pendingProps),
|
(props = workInProgress.pendingProps),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
workInProgress.memoizedProps !== props ||
|
workInProgress.memoizedProps !== props ||
|
||||||
(props = workInProgress.memoizedProps),
|
(props = workInProgress.memoizedProps),
|
||||||
(fn = props.children),
|
(fn = props.children),
|
||||||
|
@ -3649,8 +3546,7 @@ function ReactFiberBeginWork(
|
||||||
workInProgress.stateNode.containerInfo
|
workInProgress.stateNode.containerInfo
|
||||||
),
|
),
|
||||||
(props = workInProgress.pendingProps),
|
(props = workInProgress.pendingProps),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() || workInProgress.memoizedProps !== props
|
||||||
workInProgress.memoizedProps !== props
|
|
||||||
? (null === current
|
? (null === current
|
||||||
? (workInProgress.child = reconcileChildFibers(
|
? (workInProgress.child = reconcileChildFibers(
|
||||||
workInProgress,
|
workInProgress,
|
||||||
|
@ -3681,7 +3577,7 @@ function ReactFiberBeginWork(
|
||||||
case 10:
|
case 10:
|
||||||
return (
|
return (
|
||||||
(renderExpirationTime = workInProgress.pendingProps),
|
(renderExpirationTime = workInProgress.pendingProps),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
workInProgress.memoizedProps !== renderExpirationTime
|
workInProgress.memoizedProps !== renderExpirationTime
|
||||||
? (reconcileChildren(
|
? (reconcileChildren(
|
||||||
current,
|
current,
|
||||||
|
@ -3699,7 +3595,7 @@ function ReactFiberBeginWork(
|
||||||
case 11:
|
case 11:
|
||||||
return (
|
return (
|
||||||
(renderExpirationTime = workInProgress.pendingProps.children),
|
(renderExpirationTime = workInProgress.pendingProps.children),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
(null !== renderExpirationTime &&
|
(null !== renderExpirationTime &&
|
||||||
workInProgress.memoizedProps !== renderExpirationTime)
|
workInProgress.memoizedProps !== renderExpirationTime)
|
||||||
? (reconcileChildren(
|
? (reconcileChildren(
|
||||||
|
@ -3729,7 +3625,7 @@ function ReactFiberBeginWork(
|
||||||
props = fn._currentValue;
|
props = fn._currentValue;
|
||||||
var changedBits = fn._changedBits;
|
var changedBits = fn._changedBits;
|
||||||
if (
|
if (
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
0 !== changedBits ||
|
0 !== changedBits ||
|
||||||
updateQueue !== unmaskedContext
|
updateQueue !== unmaskedContext
|
||||||
) {
|
) {
|
||||||
|
@ -3769,7 +3665,13 @@ function ReactFiberBeginWork(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
function ReactFiberCompleteWork(
|
||||||
|
config,
|
||||||
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
newContext,
|
||||||
|
hydrationContext
|
||||||
|
) {
|
||||||
function markUpdate(workInProgress) {
|
function markUpdate(workInProgress) {
|
||||||
workInProgress.effectTag |= 4;
|
workInProgress.effectTag |= 4;
|
||||||
}
|
}
|
||||||
|
@ -3802,6 +3704,9 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
||||||
popHostContext = hostContext.popHostContext,
|
popHostContext = hostContext.popHostContext,
|
||||||
getHostContext = hostContext.getHostContext,
|
getHostContext = hostContext.getHostContext,
|
||||||
popHostContainer = hostContext.popHostContainer,
|
popHostContainer = hostContext.popHostContainer,
|
||||||
|
popLegacyContextProvider = legacyContext.popContextProvider,
|
||||||
|
popTopLevelLegacyContextObject = legacyContext.popTopLevelContextObject,
|
||||||
|
popProvider = newContext.popProvider,
|
||||||
prepareToHydrateHostInstance =
|
prepareToHydrateHostInstance =
|
||||||
hydrationContext.prepareToHydrateHostInstance,
|
hydrationContext.prepareToHydrateHostInstance,
|
||||||
prepareToHydrateHostTextInstance =
|
prepareToHydrateHostTextInstance =
|
||||||
|
@ -3901,7 +3806,7 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
||||||
return null;
|
return null;
|
||||||
case 2:
|
case 2:
|
||||||
return (
|
return (
|
||||||
popContextProvider(workInProgress),
|
popLegacyContextProvider(workInProgress),
|
||||||
(current = workInProgress.stateNode),
|
(current = workInProgress.stateNode),
|
||||||
(newProps = workInProgress.updateQueue),
|
(newProps = workInProgress.updateQueue),
|
||||||
null !== newProps &&
|
null !== newProps &&
|
||||||
|
@ -3914,8 +3819,7 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
||||||
);
|
);
|
||||||
case 3:
|
case 3:
|
||||||
popHostContainer(workInProgress);
|
popHostContainer(workInProgress);
|
||||||
pop(didPerformWorkStackCursor, workInProgress);
|
popTopLevelLegacyContextObject(workInProgress);
|
||||||
pop(contextStackCursor, workInProgress);
|
|
||||||
newProps = workInProgress.stateNode;
|
newProps = workInProgress.stateNode;
|
||||||
newProps.pendingContext &&
|
newProps.pendingContext &&
|
||||||
((newProps.context = newProps.pendingContext),
|
((newProps.context = newProps.pendingContext),
|
||||||
|
@ -4099,11 +4003,16 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
||||||
}
|
}
|
||||||
function ReactFiberUnwindWork(
|
function ReactFiberUnwindWork(
|
||||||
hostContext,
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
newContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
isAlreadyFailedLegacyErrorBoundary
|
isAlreadyFailedLegacyErrorBoundary
|
||||||
) {
|
) {
|
||||||
var popHostContainer = hostContext.popHostContainer,
|
var popHostContainer = hostContext.popHostContainer,
|
||||||
popHostContext = hostContext.popHostContext;
|
popHostContext = hostContext.popHostContext,
|
||||||
|
popLegacyContextProvider = legacyContext.popContextProvider,
|
||||||
|
popTopLevelLegacyContextObject = legacyContext.popTopLevelContextObject,
|
||||||
|
popProvider = newContext.popProvider;
|
||||||
return {
|
return {
|
||||||
throwException: function(returnFiber, sourceFiber, rawValue) {
|
throwException: function(returnFiber, sourceFiber, rawValue) {
|
||||||
sourceFiber.effectTag |= 512;
|
sourceFiber.effectTag |= 512;
|
||||||
|
@ -4144,7 +4053,7 @@ function ReactFiberUnwindWork(
|
||||||
unwindWork: function(workInProgress) {
|
unwindWork: function(workInProgress) {
|
||||||
switch (workInProgress.tag) {
|
switch (workInProgress.tag) {
|
||||||
case 2:
|
case 2:
|
||||||
popContextProvider(workInProgress);
|
popLegacyContextProvider(workInProgress);
|
||||||
var effectTag = workInProgress.effectTag;
|
var effectTag = workInProgress.effectTag;
|
||||||
return effectTag & 1024
|
return effectTag & 1024
|
||||||
? ((workInProgress.effectTag = (effectTag & -1025) | 64),
|
? ((workInProgress.effectTag = (effectTag & -1025) | 64),
|
||||||
|
@ -4153,8 +4062,7 @@ function ReactFiberUnwindWork(
|
||||||
case 3:
|
case 3:
|
||||||
return (
|
return (
|
||||||
popHostContainer(workInProgress),
|
popHostContainer(workInProgress),
|
||||||
pop(didPerformWorkStackCursor, workInProgress),
|
popTopLevelLegacyContextObject(workInProgress),
|
||||||
pop(contextStackCursor, workInProgress),
|
|
||||||
(effectTag = workInProgress.effectTag),
|
(effectTag = workInProgress.effectTag),
|
||||||
effectTag & 1024
|
effectTag & 1024
|
||||||
? ((workInProgress.effectTag = (effectTag & -1025) | 64),
|
? ((workInProgress.effectTag = (effectTag & -1025) | 64),
|
||||||
|
@ -4170,6 +4078,25 @@ function ReactFiberUnwindWork(
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
unwindInterruptedWork: function(interruptedWork) {
|
||||||
|
switch (interruptedWork.tag) {
|
||||||
|
case 2:
|
||||||
|
popLegacyContextProvider(interruptedWork);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
popHostContainer(interruptedWork);
|
||||||
|
popTopLevelLegacyContextObject(interruptedWork);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
popHostContext(interruptedWork);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
popHostContainer(interruptedWork);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
popProvider(interruptedWork);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4425,7 +4352,7 @@ function ReactFiberCommitWork(
|
||||||
invariant(!1, "Mutating reconciler is disabled.");
|
invariant(!1, "Mutating reconciler is disabled.");
|
||||||
}
|
}
|
||||||
var NO_CONTEXT = {};
|
var NO_CONTEXT = {};
|
||||||
function ReactFiberHostContext(config) {
|
function ReactFiberHostContext(config, stack) {
|
||||||
function requiredContext(c) {
|
function requiredContext(c) {
|
||||||
invariant(
|
invariant(
|
||||||
c !== NO_CONTEXT,
|
c !== NO_CONTEXT,
|
||||||
|
@ -4434,10 +4361,13 @@ function ReactFiberHostContext(config) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
var getChildHostContext = config.getChildHostContext,
|
var getChildHostContext = config.getChildHostContext,
|
||||||
getRootHostContext = config.getRootHostContext,
|
getRootHostContext = config.getRootHostContext;
|
||||||
contextStackCursor = { current: NO_CONTEXT },
|
config = stack.createCursor;
|
||||||
contextFiberStackCursor = { current: NO_CONTEXT },
|
var push = stack.push,
|
||||||
rootInstanceStackCursor = { current: NO_CONTEXT };
|
pop = stack.pop,
|
||||||
|
contextStackCursor = config(NO_CONTEXT),
|
||||||
|
contextFiberStackCursor = config(NO_CONTEXT),
|
||||||
|
rootInstanceStackCursor = config(NO_CONTEXT);
|
||||||
return {
|
return {
|
||||||
getHostContext: function() {
|
getHostContext: function() {
|
||||||
return requiredContext(contextStackCursor.current);
|
return requiredContext(contextStackCursor.current);
|
||||||
|
@ -4467,10 +4397,6 @@ function ReactFiberHostContext(config) {
|
||||||
context !== rootInstance &&
|
context !== rootInstance &&
|
||||||
(push(contextFiberStackCursor, fiber, fiber),
|
(push(contextFiberStackCursor, fiber, fiber),
|
||||||
push(contextStackCursor, rootInstance, fiber));
|
push(contextStackCursor, rootInstance, fiber));
|
||||||
},
|
|
||||||
resetHostContainer: function() {
|
|
||||||
contextStackCursor.current = NO_CONTEXT;
|
|
||||||
rootInstanceStackCursor.current = NO_CONTEXT;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4630,22 +4556,198 @@ function ReactFiberHydrationContext(config) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ReactFiberScheduler(config) {
|
function ReactFiberLegacyContext(stack) {
|
||||||
function resetContextStack() {
|
function cacheContext(workInProgress, unmaskedContext, maskedContext) {
|
||||||
for (; -1 < index; ) (valueStack[index] = null), index--;
|
workInProgress = workInProgress.stateNode;
|
||||||
|
workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
|
||||||
|
workInProgress.__reactInternalMemoizedMaskedChildContext = maskedContext;
|
||||||
|
}
|
||||||
|
function isContextProvider(fiber) {
|
||||||
|
return 2 === fiber.tag && null != fiber.type.childContextTypes;
|
||||||
|
}
|
||||||
|
function processChildContext(fiber, parentContext) {
|
||||||
|
var instance = fiber.stateNode,
|
||||||
|
childContextTypes = fiber.type.childContextTypes;
|
||||||
|
if ("function" !== typeof instance.getChildContext) return parentContext;
|
||||||
|
instance = instance.getChildContext();
|
||||||
|
for (var contextKey in instance)
|
||||||
|
invariant(
|
||||||
|
contextKey in childContextTypes,
|
||||||
|
'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
|
||||||
|
getComponentName(fiber) || "Unknown",
|
||||||
|
contextKey
|
||||||
|
);
|
||||||
|
return Object.assign({}, parentContext, instance);
|
||||||
|
}
|
||||||
|
var createCursor = stack.createCursor,
|
||||||
|
push = stack.push,
|
||||||
|
pop = stack.pop,
|
||||||
|
contextStackCursor = createCursor(emptyObject),
|
||||||
|
didPerformWorkStackCursor = createCursor(!1),
|
||||||
previousContext = emptyObject;
|
previousContext = emptyObject;
|
||||||
contextStackCursor.current = emptyObject;
|
return {
|
||||||
didPerformWorkStackCursor.current = !1;
|
getUnmaskedContext: function(workInProgress) {
|
||||||
resetHostContainer();
|
return isContextProvider(workInProgress)
|
||||||
for (var i = index$1; -1 < i; i--) {
|
? previousContext
|
||||||
var context = stack[i].type.context;
|
: contextStackCursor.current;
|
||||||
context._currentValue = context._defaultValue;
|
},
|
||||||
context._changedBits = 0;
|
cacheContext: cacheContext,
|
||||||
changedBitsStack[i] = null;
|
getMaskedContext: function(workInProgress, unmaskedContext) {
|
||||||
currentValueStack[i] = null;
|
var contextTypes = workInProgress.type.contextTypes;
|
||||||
stack[i] = null;
|
if (!contextTypes) return emptyObject;
|
||||||
|
var instance = workInProgress.stateNode;
|
||||||
|
if (
|
||||||
|
instance &&
|
||||||
|
instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext
|
||||||
|
)
|
||||||
|
return instance.__reactInternalMemoizedMaskedChildContext;
|
||||||
|
var context = {},
|
||||||
|
key;
|
||||||
|
for (key in contextTypes) context[key] = unmaskedContext[key];
|
||||||
|
instance && cacheContext(workInProgress, unmaskedContext, context);
|
||||||
|
return context;
|
||||||
|
},
|
||||||
|
hasContextChanged: function() {
|
||||||
|
return didPerformWorkStackCursor.current;
|
||||||
|
},
|
||||||
|
isContextConsumer: function(fiber) {
|
||||||
|
return 2 === fiber.tag && null != fiber.type.contextTypes;
|
||||||
|
},
|
||||||
|
isContextProvider: isContextProvider,
|
||||||
|
popContextProvider: function(fiber) {
|
||||||
|
isContextProvider(fiber) &&
|
||||||
|
(pop(didPerformWorkStackCursor, fiber), pop(contextStackCursor, fiber));
|
||||||
|
},
|
||||||
|
popTopLevelContextObject: function(fiber) {
|
||||||
|
pop(didPerformWorkStackCursor, fiber);
|
||||||
|
pop(contextStackCursor, fiber);
|
||||||
|
},
|
||||||
|
pushTopLevelContextObject: function(fiber, context, didChange) {
|
||||||
|
invariant(
|
||||||
|
null == contextStackCursor.cursor,
|
||||||
|
"Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."
|
||||||
|
);
|
||||||
|
push(contextStackCursor, context, fiber);
|
||||||
|
push(didPerformWorkStackCursor, didChange, fiber);
|
||||||
|
},
|
||||||
|
processChildContext: processChildContext,
|
||||||
|
pushContextProvider: function(workInProgress) {
|
||||||
|
if (!isContextProvider(workInProgress)) return !1;
|
||||||
|
var instance = workInProgress.stateNode;
|
||||||
|
instance =
|
||||||
|
(instance && instance.__reactInternalMemoizedMergedChildContext) ||
|
||||||
|
emptyObject;
|
||||||
|
previousContext = contextStackCursor.current;
|
||||||
|
push(contextStackCursor, instance, workInProgress);
|
||||||
|
push(
|
||||||
|
didPerformWorkStackCursor,
|
||||||
|
didPerformWorkStackCursor.current,
|
||||||
|
workInProgress
|
||||||
|
);
|
||||||
|
return !0;
|
||||||
|
},
|
||||||
|
invalidateContextProvider: function(workInProgress, didChange) {
|
||||||
|
var instance = workInProgress.stateNode;
|
||||||
|
invariant(
|
||||||
|
instance,
|
||||||
|
"Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."
|
||||||
|
);
|
||||||
|
if (didChange) {
|
||||||
|
var mergedContext = processChildContext(
|
||||||
|
workInProgress,
|
||||||
|
previousContext
|
||||||
|
);
|
||||||
|
instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
||||||
|
pop(didPerformWorkStackCursor, workInProgress);
|
||||||
|
pop(contextStackCursor, workInProgress);
|
||||||
|
push(contextStackCursor, mergedContext, workInProgress);
|
||||||
|
} else pop(didPerformWorkStackCursor, workInProgress);
|
||||||
|
push(didPerformWorkStackCursor, didChange, workInProgress);
|
||||||
|
},
|
||||||
|
findCurrentUnmaskedContext: function(fiber) {
|
||||||
|
for (
|
||||||
|
invariant(
|
||||||
|
2 === isFiberMountedImpl(fiber) && 2 === fiber.tag,
|
||||||
|
"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."
|
||||||
|
);
|
||||||
|
3 !== fiber.tag;
|
||||||
|
|
||||||
|
) {
|
||||||
|
if (isContextProvider(fiber))
|
||||||
|
return fiber.stateNode.__reactInternalMemoizedMergedChildContext;
|
||||||
|
fiber = fiber["return"];
|
||||||
|
invariant(
|
||||||
|
fiber,
|
||||||
|
"Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return fiber.stateNode.context;
|
||||||
}
|
}
|
||||||
index$1 = -1;
|
};
|
||||||
|
}
|
||||||
|
function ReactFiberNewContext(stack) {
|
||||||
|
var createCursor = stack.createCursor,
|
||||||
|
push = stack.push,
|
||||||
|
pop = stack.pop,
|
||||||
|
providerCursor = createCursor(null),
|
||||||
|
valueCursor = createCursor(null),
|
||||||
|
changedBitsCursor = createCursor(0);
|
||||||
|
return {
|
||||||
|
pushProvider: function(providerFiber) {
|
||||||
|
var context = providerFiber.type.context;
|
||||||
|
push(changedBitsCursor, context._changedBits, providerFiber);
|
||||||
|
push(valueCursor, context._currentValue, providerFiber);
|
||||||
|
push(providerCursor, providerFiber, providerFiber);
|
||||||
|
context._currentValue = providerFiber.pendingProps.value;
|
||||||
|
context._changedBits = providerFiber.stateNode;
|
||||||
|
},
|
||||||
|
popProvider: function(providerFiber) {
|
||||||
|
var changedBits = changedBitsCursor.current,
|
||||||
|
currentValue = valueCursor.current;
|
||||||
|
pop(providerCursor, providerFiber);
|
||||||
|
pop(valueCursor, providerFiber);
|
||||||
|
pop(changedBitsCursor, providerFiber);
|
||||||
|
providerFiber = providerFiber.type.context;
|
||||||
|
providerFiber._currentValue = currentValue;
|
||||||
|
providerFiber._changedBits = changedBits;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function ReactFiberStack() {
|
||||||
|
var valueStack = [],
|
||||||
|
index = -1;
|
||||||
|
return {
|
||||||
|
createCursor: function(defaultValue) {
|
||||||
|
return { current: defaultValue };
|
||||||
|
},
|
||||||
|
isEmpty: function() {
|
||||||
|
return -1 === index;
|
||||||
|
},
|
||||||
|
pop: function(cursor) {
|
||||||
|
0 > index ||
|
||||||
|
((cursor.current = valueStack[index]),
|
||||||
|
(valueStack[index] = null),
|
||||||
|
index--);
|
||||||
|
},
|
||||||
|
push: function(cursor, value) {
|
||||||
|
index++;
|
||||||
|
valueStack[index] = cursor.current;
|
||||||
|
cursor.current = value;
|
||||||
|
},
|
||||||
|
checkThatStackIsEmpty: function() {},
|
||||||
|
resetStackAfterFatalErrorInDev: function() {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function ReactFiberScheduler(config) {
|
||||||
|
function resetStack() {
|
||||||
|
if (null !== nextUnitOfWork)
|
||||||
|
for (
|
||||||
|
var interruptedWork = nextUnitOfWork["return"];
|
||||||
|
null !== interruptedWork;
|
||||||
|
|
||||||
|
)
|
||||||
|
unwindInterruptedWork(interruptedWork),
|
||||||
|
(interruptedWork = interruptedWork["return"]);
|
||||||
nextRoot = null;
|
nextRoot = null;
|
||||||
nextRenderExpirationTime = 0;
|
nextRenderExpirationTime = 0;
|
||||||
nextUnitOfWork = null;
|
nextUnitOfWork = null;
|
||||||
|
@ -4751,7 +4853,7 @@ function ReactFiberScheduler(config) {
|
||||||
root !== nextRoot ||
|
root !== nextRoot ||
|
||||||
null === nextUnitOfWork
|
null === nextUnitOfWork
|
||||||
)
|
)
|
||||||
resetContextStack(),
|
resetStack(),
|
||||||
(nextRoot = root),
|
(nextRoot = root),
|
||||||
(nextRenderExpirationTime = expirationTime),
|
(nextRenderExpirationTime = expirationTime),
|
||||||
(nextUnitOfWork = createWorkInProgress(
|
(nextUnitOfWork = createWorkInProgress(
|
||||||
|
@ -4881,7 +4983,7 @@ function ReactFiberScheduler(config) {
|
||||||
!isWorking &&
|
!isWorking &&
|
||||||
0 !== nextRenderExpirationTime &&
|
0 !== nextRenderExpirationTime &&
|
||||||
expirationTime < nextRenderExpirationTime &&
|
expirationTime < nextRenderExpirationTime &&
|
||||||
resetContextStack();
|
resetStack();
|
||||||
(nextRoot === root && isWorking) ||
|
(nextRoot === root && isWorking) ||
|
||||||
requestWork(root, expirationTime);
|
requestWork(root, expirationTime);
|
||||||
nestedUpdateCount > NESTED_UPDATE_LIMIT &&
|
nestedUpdateCount > NESTED_UPDATE_LIMIT &&
|
||||||
|
@ -5225,25 +5327,37 @@ function ReactFiberScheduler(config) {
|
||||||
nextFlushedRoot.remainingExpirationTime = 0;
|
nextFlushedRoot.remainingExpirationTime = 0;
|
||||||
hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error));
|
hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error));
|
||||||
}
|
}
|
||||||
var hostContext = ReactFiberHostContext(config),
|
var stack = ReactFiberStack(),
|
||||||
hydrationContext = ReactFiberHydrationContext(config),
|
hostContext = ReactFiberHostContext(config, stack),
|
||||||
resetHostContainer = hostContext.resetHostContainer,
|
legacyContext = ReactFiberLegacyContext(stack);
|
||||||
|
stack = ReactFiberNewContext(stack);
|
||||||
|
var hydrationContext = ReactFiberHydrationContext(config),
|
||||||
beginWork = ReactFiberBeginWork(
|
beginWork = ReactFiberBeginWork(
|
||||||
config,
|
config,
|
||||||
hostContext,
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
stack,
|
||||||
hydrationContext,
|
hydrationContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
computeExpirationForFiber
|
computeExpirationForFiber
|
||||||
).beginWork,
|
).beginWork,
|
||||||
completeWork = ReactFiberCompleteWork(config, hostContext, hydrationContext)
|
completeWork = ReactFiberCompleteWork(
|
||||||
.completeWork;
|
config,
|
||||||
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
stack,
|
||||||
|
hydrationContext
|
||||||
|
).completeWork;
|
||||||
hostContext = ReactFiberUnwindWork(
|
hostContext = ReactFiberUnwindWork(
|
||||||
hostContext,
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
stack,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
isAlreadyFailedLegacyErrorBoundary
|
isAlreadyFailedLegacyErrorBoundary
|
||||||
);
|
);
|
||||||
var throwException = hostContext.throwException,
|
var throwException = hostContext.throwException,
|
||||||
unwindWork = hostContext.unwindWork;
|
unwindWork = hostContext.unwindWork,
|
||||||
|
unwindInterruptedWork = hostContext.unwindInterruptedWork;
|
||||||
hostContext = ReactFiberCommitWork(
|
hostContext = ReactFiberCommitWork(
|
||||||
config,
|
config,
|
||||||
onCommitPhaseError,
|
onCommitPhaseError,
|
||||||
|
@ -5402,7 +5516,8 @@ function ReactFiberScheduler(config) {
|
||||||
result <= lastUniqueAsyncExpiration &&
|
result <= lastUniqueAsyncExpiration &&
|
||||||
(result = lastUniqueAsyncExpiration + 1);
|
(result = lastUniqueAsyncExpiration + 1);
|
||||||
return (lastUniqueAsyncExpiration = result);
|
return (lastUniqueAsyncExpiration = result);
|
||||||
}
|
},
|
||||||
|
legacyContext: legacyContext
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ReactFiberReconciler$1(config) {
|
function ReactFiberReconciler$1(config) {
|
||||||
|
@ -5417,27 +5532,7 @@ function ReactFiberReconciler$1(config) {
|
||||||
currentTime = container.current;
|
currentTime = container.current;
|
||||||
if (parentComponent) {
|
if (parentComponent) {
|
||||||
parentComponent = parentComponent._reactInternalFiber;
|
parentComponent = parentComponent._reactInternalFiber;
|
||||||
var parentContext;
|
var parentContext = findCurrentUnmaskedContext(parentComponent);
|
||||||
b: {
|
|
||||||
invariant(
|
|
||||||
2 === isFiberMountedImpl(parentComponent) &&
|
|
||||||
2 === parentComponent.tag,
|
|
||||||
"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."
|
|
||||||
);
|
|
||||||
for (parentContext = parentComponent; 3 !== parentContext.tag; ) {
|
|
||||||
if (isContextProvider(parentContext)) {
|
|
||||||
parentContext =
|
|
||||||
parentContext.stateNode.__reactInternalMemoizedMergedChildContext;
|
|
||||||
break b;
|
|
||||||
}
|
|
||||||
parentContext = parentContext["return"];
|
|
||||||
invariant(
|
|
||||||
parentContext,
|
|
||||||
"Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
parentContext = parentContext.stateNode.context;
|
|
||||||
}
|
|
||||||
parentComponent = isContextProvider(parentComponent)
|
parentComponent = isContextProvider(parentComponent)
|
||||||
? processChildContext(parentComponent, parentContext)
|
? processChildContext(parentComponent, parentContext)
|
||||||
: parentContext;
|
: parentContext;
|
||||||
|
@ -5466,7 +5561,11 @@ function ReactFiberReconciler$1(config) {
|
||||||
config = ReactFiberScheduler(config);
|
config = ReactFiberScheduler(config);
|
||||||
var recalculateCurrentTime = config.recalculateCurrentTime,
|
var recalculateCurrentTime = config.recalculateCurrentTime,
|
||||||
computeExpirationForFiber = config.computeExpirationForFiber,
|
computeExpirationForFiber = config.computeExpirationForFiber,
|
||||||
scheduleWork = config.scheduleWork;
|
scheduleWork = config.scheduleWork,
|
||||||
|
legacyContext = config.legacyContext,
|
||||||
|
findCurrentUnmaskedContext = legacyContext.findCurrentUnmaskedContext,
|
||||||
|
isContextProvider = legacyContext.isContextProvider,
|
||||||
|
processChildContext = legacyContext.processChildContext;
|
||||||
return {
|
return {
|
||||||
createContainer: function(containerInfo, isAsync, hydrate) {
|
createContainer: function(containerInfo, isAsync, hydrate) {
|
||||||
isAsync = new FiberNode(3, null, null, isAsync ? 3 : 0);
|
isAsync = new FiberNode(3, null, null, isAsync ? 3 : 0);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1822,141 +1822,6 @@ function findCurrentHostFiberWithNoPortals(parent) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var valueStack = [],
|
|
||||||
index = -1;
|
|
||||||
function pop(cursor) {
|
|
||||||
0 > index ||
|
|
||||||
((cursor.current = valueStack[index]), (valueStack[index] = null), index--);
|
|
||||||
}
|
|
||||||
function push(cursor, value) {
|
|
||||||
index++;
|
|
||||||
valueStack[index] = cursor.current;
|
|
||||||
cursor.current = value;
|
|
||||||
}
|
|
||||||
function getStackAddendumByWorkInProgressFiber(workInProgress) {
|
|
||||||
var info = "";
|
|
||||||
do {
|
|
||||||
a: switch (workInProgress.tag) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 5:
|
|
||||||
var owner = workInProgress._debugOwner,
|
|
||||||
source = workInProgress._debugSource;
|
|
||||||
var JSCompiler_inline_result = getComponentName(workInProgress);
|
|
||||||
var ownerName = null;
|
|
||||||
owner && (ownerName = getComponentName(owner));
|
|
||||||
owner = source;
|
|
||||||
JSCompiler_inline_result =
|
|
||||||
"\n in " +
|
|
||||||
(JSCompiler_inline_result || "Unknown") +
|
|
||||||
(owner
|
|
||||||
? " (at " +
|
|
||||||
owner.fileName.replace(/^.*[\\\/]/, "") +
|
|
||||||
":" +
|
|
||||||
owner.lineNumber +
|
|
||||||
")"
|
|
||||||
: ownerName ? " (created by " + ownerName + ")" : "");
|
|
||||||
break a;
|
|
||||||
default:
|
|
||||||
JSCompiler_inline_result = "";
|
|
||||||
}
|
|
||||||
info += JSCompiler_inline_result;
|
|
||||||
workInProgress = workInProgress["return"];
|
|
||||||
} while (workInProgress);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
var _require = require("ReactFeatureFlags"),
|
|
||||||
enableGetDerivedStateFromCatch = _require.enableGetDerivedStateFromCatch,
|
|
||||||
debugRenderPhaseSideEffects = _require.debugRenderPhaseSideEffects,
|
|
||||||
debugRenderPhaseSideEffectsForStrictMode =
|
|
||||||
_require.debugRenderPhaseSideEffectsForStrictMode;
|
|
||||||
new Set();
|
|
||||||
var contextStackCursor = { current: emptyObject },
|
|
||||||
didPerformWorkStackCursor = { current: !1 },
|
|
||||||
previousContext = emptyObject;
|
|
||||||
function getUnmaskedContext(workInProgress) {
|
|
||||||
return isContextProvider(workInProgress)
|
|
||||||
? previousContext
|
|
||||||
: contextStackCursor.current;
|
|
||||||
}
|
|
||||||
function getMaskedContext(workInProgress, unmaskedContext) {
|
|
||||||
var contextTypes = workInProgress.type.contextTypes;
|
|
||||||
if (!contextTypes) return emptyObject;
|
|
||||||
var instance = workInProgress.stateNode;
|
|
||||||
if (
|
|
||||||
instance &&
|
|
||||||
instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext
|
|
||||||
)
|
|
||||||
return instance.__reactInternalMemoizedMaskedChildContext;
|
|
||||||
var context = {},
|
|
||||||
key;
|
|
||||||
for (key in contextTypes) context[key] = unmaskedContext[key];
|
|
||||||
instance &&
|
|
||||||
((workInProgress = workInProgress.stateNode),
|
|
||||||
(workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext),
|
|
||||||
(workInProgress.__reactInternalMemoizedMaskedChildContext = context));
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
function isContextProvider(fiber) {
|
|
||||||
return 2 === fiber.tag && null != fiber.type.childContextTypes;
|
|
||||||
}
|
|
||||||
function popContextProvider(fiber) {
|
|
||||||
isContextProvider(fiber) &&
|
|
||||||
(pop(didPerformWorkStackCursor, fiber), pop(contextStackCursor, fiber));
|
|
||||||
}
|
|
||||||
function pushTopLevelContextObject(fiber, context, didChange) {
|
|
||||||
invariant(
|
|
||||||
null == contextStackCursor.cursor,
|
|
||||||
"Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."
|
|
||||||
);
|
|
||||||
push(contextStackCursor, context, fiber);
|
|
||||||
push(didPerformWorkStackCursor, didChange, fiber);
|
|
||||||
}
|
|
||||||
function processChildContext(fiber, parentContext) {
|
|
||||||
var instance = fiber.stateNode,
|
|
||||||
childContextTypes = fiber.type.childContextTypes;
|
|
||||||
if ("function" !== typeof instance.getChildContext) return parentContext;
|
|
||||||
instance = instance.getChildContext();
|
|
||||||
for (var contextKey in instance)
|
|
||||||
invariant(
|
|
||||||
contextKey in childContextTypes,
|
|
||||||
'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
|
|
||||||
getComponentName(fiber) || "Unknown",
|
|
||||||
contextKey
|
|
||||||
);
|
|
||||||
return Object.assign({}, parentContext, instance);
|
|
||||||
}
|
|
||||||
function pushContextProvider(workInProgress) {
|
|
||||||
if (!isContextProvider(workInProgress)) return !1;
|
|
||||||
var instance = workInProgress.stateNode;
|
|
||||||
instance =
|
|
||||||
(instance && instance.__reactInternalMemoizedMergedChildContext) ||
|
|
||||||
emptyObject;
|
|
||||||
previousContext = contextStackCursor.current;
|
|
||||||
push(contextStackCursor, instance, workInProgress);
|
|
||||||
push(
|
|
||||||
didPerformWorkStackCursor,
|
|
||||||
didPerformWorkStackCursor.current,
|
|
||||||
workInProgress
|
|
||||||
);
|
|
||||||
return !0;
|
|
||||||
}
|
|
||||||
function invalidateContextProvider(workInProgress, didChange) {
|
|
||||||
var instance = workInProgress.stateNode;
|
|
||||||
invariant(
|
|
||||||
instance,
|
|
||||||
"Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."
|
|
||||||
);
|
|
||||||
if (didChange) {
|
|
||||||
var mergedContext = processChildContext(workInProgress, previousContext);
|
|
||||||
instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
|
||||||
pop(didPerformWorkStackCursor, workInProgress);
|
|
||||||
pop(contextStackCursor, workInProgress);
|
|
||||||
push(contextStackCursor, mergedContext, workInProgress);
|
|
||||||
} else pop(didPerformWorkStackCursor, workInProgress);
|
|
||||||
push(didPerformWorkStackCursor, didChange, workInProgress);
|
|
||||||
}
|
|
||||||
function FiberNode(tag, pendingProps, key, mode) {
|
function FiberNode(tag, pendingProps, key, mode) {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
@ -2123,6 +1988,45 @@ function onCommitRoot(root) {
|
||||||
function onCommitUnmount(fiber) {
|
function onCommitUnmount(fiber) {
|
||||||
"function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(fiber);
|
"function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(fiber);
|
||||||
}
|
}
|
||||||
|
function getStackAddendumByWorkInProgressFiber(workInProgress) {
|
||||||
|
var info = "";
|
||||||
|
do {
|
||||||
|
a: switch (workInProgress.tag) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 5:
|
||||||
|
var owner = workInProgress._debugOwner,
|
||||||
|
source = workInProgress._debugSource;
|
||||||
|
var JSCompiler_inline_result = getComponentName(workInProgress);
|
||||||
|
var ownerName = null;
|
||||||
|
owner && (ownerName = getComponentName(owner));
|
||||||
|
owner = source;
|
||||||
|
JSCompiler_inline_result =
|
||||||
|
"\n in " +
|
||||||
|
(JSCompiler_inline_result || "Unknown") +
|
||||||
|
(owner
|
||||||
|
? " (at " +
|
||||||
|
owner.fileName.replace(/^.*[\\\/]/, "") +
|
||||||
|
":" +
|
||||||
|
owner.lineNumber +
|
||||||
|
")"
|
||||||
|
: ownerName ? " (created by " + ownerName + ")" : "");
|
||||||
|
break a;
|
||||||
|
default:
|
||||||
|
JSCompiler_inline_result = "";
|
||||||
|
}
|
||||||
|
info += JSCompiler_inline_result;
|
||||||
|
workInProgress = workInProgress["return"];
|
||||||
|
} while (workInProgress);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
var _require = require("ReactFeatureFlags"),
|
||||||
|
enableGetDerivedStateFromCatch = _require.enableGetDerivedStateFromCatch,
|
||||||
|
debugRenderPhaseSideEffects = _require.debugRenderPhaseSideEffects,
|
||||||
|
debugRenderPhaseSideEffectsForStrictMode =
|
||||||
|
_require.debugRenderPhaseSideEffectsForStrictMode;
|
||||||
|
new Set();
|
||||||
function createUpdateQueue(baseState) {
|
function createUpdateQueue(baseState) {
|
||||||
return {
|
return {
|
||||||
baseState: baseState,
|
baseState: baseState,
|
||||||
|
@ -2294,6 +2198,7 @@ function callGetDerivedStateFromCatch(ctor, capturedValues) {
|
||||||
return resultState;
|
return resultState;
|
||||||
}
|
}
|
||||||
function ReactFiberClassComponent(
|
function ReactFiberClassComponent(
|
||||||
|
legacyContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
computeExpirationForFiber,
|
computeExpirationForFiber,
|
||||||
memoizeProps,
|
memoizeProps,
|
||||||
|
@ -2360,62 +2265,66 @@ function ReactFiberClassComponent(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var updater = {
|
var cacheContext = legacyContext.cacheContext,
|
||||||
isMounted: isMounted,
|
getMaskedContext = legacyContext.getMaskedContext,
|
||||||
enqueueSetState: function(instance, partialState, callback) {
|
getUnmaskedContext = legacyContext.getUnmaskedContext,
|
||||||
instance = instance._reactInternalFiber;
|
isContextConsumer = legacyContext.isContextConsumer,
|
||||||
callback = void 0 === callback ? null : callback;
|
hasContextChanged = legacyContext.hasContextChanged,
|
||||||
var expirationTime = computeExpirationForFiber(instance);
|
updater = {
|
||||||
insertUpdateIntoFiber(instance, {
|
isMounted: isMounted,
|
||||||
expirationTime: expirationTime,
|
enqueueSetState: function(instance, partialState, callback) {
|
||||||
partialState: partialState,
|
instance = instance._reactInternalFiber;
|
||||||
callback: callback,
|
callback = void 0 === callback ? null : callback;
|
||||||
isReplace: !1,
|
var expirationTime = computeExpirationForFiber(instance);
|
||||||
isForced: !1,
|
insertUpdateIntoFiber(instance, {
|
||||||
capturedValue: null,
|
expirationTime: expirationTime,
|
||||||
next: null
|
partialState: partialState,
|
||||||
});
|
callback: callback,
|
||||||
scheduleWork(instance, expirationTime);
|
isReplace: !1,
|
||||||
},
|
isForced: !1,
|
||||||
enqueueReplaceState: function(instance, state, callback) {
|
capturedValue: null,
|
||||||
instance = instance._reactInternalFiber;
|
next: null
|
||||||
callback = void 0 === callback ? null : callback;
|
});
|
||||||
var expirationTime = computeExpirationForFiber(instance);
|
scheduleWork(instance, expirationTime);
|
||||||
insertUpdateIntoFiber(instance, {
|
},
|
||||||
expirationTime: expirationTime,
|
enqueueReplaceState: function(instance, state, callback) {
|
||||||
partialState: state,
|
instance = instance._reactInternalFiber;
|
||||||
callback: callback,
|
callback = void 0 === callback ? null : callback;
|
||||||
isReplace: !0,
|
var expirationTime = computeExpirationForFiber(instance);
|
||||||
isForced: !1,
|
insertUpdateIntoFiber(instance, {
|
||||||
capturedValue: null,
|
expirationTime: expirationTime,
|
||||||
next: null
|
partialState: state,
|
||||||
});
|
callback: callback,
|
||||||
scheduleWork(instance, expirationTime);
|
isReplace: !0,
|
||||||
},
|
isForced: !1,
|
||||||
enqueueForceUpdate: function(instance, callback) {
|
capturedValue: null,
|
||||||
instance = instance._reactInternalFiber;
|
next: null
|
||||||
callback = void 0 === callback ? null : callback;
|
});
|
||||||
var expirationTime = computeExpirationForFiber(instance);
|
scheduleWork(instance, expirationTime);
|
||||||
insertUpdateIntoFiber(instance, {
|
},
|
||||||
expirationTime: expirationTime,
|
enqueueForceUpdate: function(instance, callback) {
|
||||||
partialState: null,
|
instance = instance._reactInternalFiber;
|
||||||
callback: callback,
|
callback = void 0 === callback ? null : callback;
|
||||||
isReplace: !1,
|
var expirationTime = computeExpirationForFiber(instance);
|
||||||
isForced: !0,
|
insertUpdateIntoFiber(instance, {
|
||||||
capturedValue: null,
|
expirationTime: expirationTime,
|
||||||
next: null
|
partialState: null,
|
||||||
});
|
callback: callback,
|
||||||
scheduleWork(instance, expirationTime);
|
isReplace: !1,
|
||||||
}
|
isForced: !0,
|
||||||
};
|
capturedValue: null,
|
||||||
|
next: null
|
||||||
|
});
|
||||||
|
scheduleWork(instance, expirationTime);
|
||||||
|
}
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
adoptClassInstance: adoptClassInstance,
|
adoptClassInstance: adoptClassInstance,
|
||||||
callGetDerivedStateFromProps: callGetDerivedStateFromProps,
|
callGetDerivedStateFromProps: callGetDerivedStateFromProps,
|
||||||
constructClassInstance: function(workInProgress, props) {
|
constructClassInstance: function(workInProgress, props) {
|
||||||
var ctor = workInProgress.type,
|
var ctor = workInProgress.type,
|
||||||
unmaskedContext = getUnmaskedContext(workInProgress),
|
unmaskedContext = getUnmaskedContext(workInProgress),
|
||||||
needsContext =
|
needsContext = isContextConsumer(workInProgress),
|
||||||
2 === workInProgress.tag && null != workInProgress.type.contextTypes,
|
|
||||||
context = needsContext
|
context = needsContext
|
||||||
? getMaskedContext(workInProgress, unmaskedContext)
|
? getMaskedContext(workInProgress, unmaskedContext)
|
||||||
: emptyObject;
|
: emptyObject;
|
||||||
|
@ -2436,10 +2345,7 @@ function ReactFiberClassComponent(
|
||||||
workInProgress.memoizedState,
|
workInProgress.memoizedState,
|
||||||
props
|
props
|
||||||
));
|
));
|
||||||
needsContext &&
|
needsContext && cacheContext(workInProgress, unmaskedContext, context);
|
||||||
((workInProgress = workInProgress.stateNode),
|
|
||||||
(workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext),
|
|
||||||
(workInProgress.__reactInternalMemoizedMaskedChildContext = context));
|
|
||||||
return ctor;
|
return ctor;
|
||||||
},
|
},
|
||||||
mountClassInstance: function(workInProgress, renderExpirationTime) {
|
mountClassInstance: function(workInProgress, renderExpirationTime) {
|
||||||
|
@ -2539,7 +2445,7 @@ function ReactFiberClassComponent(
|
||||||
!(
|
!(
|
||||||
oldProps !== newProps ||
|
oldProps !== newProps ||
|
||||||
oldState !== renderExpirationTime ||
|
oldState !== renderExpirationTime ||
|
||||||
didPerformWorkStackCursor.current ||
|
hasContextChanged() ||
|
||||||
(null !== workInProgress.updateQueue &&
|
(null !== workInProgress.updateQueue &&
|
||||||
workInProgress.updateQueue.hasForceUpdate)
|
workInProgress.updateQueue.hasForceUpdate)
|
||||||
)
|
)
|
||||||
|
@ -2643,7 +2549,7 @@ function ReactFiberClassComponent(
|
||||||
!(
|
!(
|
||||||
oldProps !== newProps ||
|
oldProps !== newProps ||
|
||||||
oldContext !== renderExpirationTime ||
|
oldContext !== renderExpirationTime ||
|
||||||
didPerformWorkStackCursor.current ||
|
hasContextChanged() ||
|
||||||
(null !== workInProgress.updateQueue &&
|
(null !== workInProgress.updateQueue &&
|
||||||
workInProgress.updateQueue.hasForceUpdate)
|
workInProgress.updateQueue.hasForceUpdate)
|
||||||
)
|
)
|
||||||
|
@ -3366,34 +3272,12 @@ function ChildReconciler(shouldTrackSideEffects) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var reconcileChildFibers = ChildReconciler(!0),
|
var reconcileChildFibers = ChildReconciler(!0),
|
||||||
mountChildFibers = ChildReconciler(!1),
|
mountChildFibers = ChildReconciler(!1);
|
||||||
changedBitsStack = [],
|
|
||||||
currentValueStack = [],
|
|
||||||
stack = [],
|
|
||||||
index$1 = -1;
|
|
||||||
function pushProvider(providerFiber) {
|
|
||||||
var context = providerFiber.type.context;
|
|
||||||
index$1 += 1;
|
|
||||||
changedBitsStack[index$1] = context._changedBits;
|
|
||||||
currentValueStack[index$1] = context._currentValue;
|
|
||||||
stack[index$1] = providerFiber;
|
|
||||||
context._currentValue = providerFiber.pendingProps.value;
|
|
||||||
context._changedBits = providerFiber.stateNode;
|
|
||||||
}
|
|
||||||
function popProvider(providerFiber) {
|
|
||||||
var changedBits = changedBitsStack[index$1],
|
|
||||||
currentValue = currentValueStack[index$1];
|
|
||||||
changedBitsStack[index$1] = null;
|
|
||||||
currentValueStack[index$1] = null;
|
|
||||||
stack[index$1] = null;
|
|
||||||
--index$1;
|
|
||||||
providerFiber = providerFiber.type.context;
|
|
||||||
providerFiber._currentValue = currentValue;
|
|
||||||
providerFiber._changedBits = changedBits;
|
|
||||||
}
|
|
||||||
function ReactFiberBeginWork(
|
function ReactFiberBeginWork(
|
||||||
config,
|
config,
|
||||||
hostContext,
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
newContext,
|
||||||
hydrationContext,
|
hydrationContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
computeExpirationForFiber
|
computeExpirationForFiber
|
||||||
|
@ -3499,7 +3383,12 @@ function ReactFiberBeginWork(
|
||||||
changedBits,
|
changedBits,
|
||||||
renderExpirationTime
|
renderExpirationTime
|
||||||
) {
|
) {
|
||||||
for (var fiber = workInProgress.child; null !== fiber; ) {
|
var fiber = workInProgress.child;
|
||||||
|
for (
|
||||||
|
null !== fiber && (fiber["return"] = workInProgress);
|
||||||
|
null !== fiber;
|
||||||
|
|
||||||
|
) {
|
||||||
switch (fiber.tag) {
|
switch (fiber.tag) {
|
||||||
case 12:
|
case 12:
|
||||||
var nextFiber = fiber.stateNode | 0;
|
var nextFiber = fiber.stateNode | 0;
|
||||||
|
@ -3558,7 +3447,7 @@ function ReactFiberBeginWork(
|
||||||
var context = workInProgress.type.context,
|
var context = workInProgress.type.context,
|
||||||
newProps = workInProgress.pendingProps,
|
newProps = workInProgress.pendingProps,
|
||||||
oldProps = workInProgress.memoizedProps;
|
oldProps = workInProgress.memoizedProps;
|
||||||
if (!didPerformWorkStackCursor.current && oldProps === newProps)
|
if (!hasLegacyContextChanged() && oldProps === newProps)
|
||||||
return (
|
return (
|
||||||
(workInProgress.stateNode = 0),
|
(workInProgress.stateNode = 0),
|
||||||
pushProvider(workInProgress),
|
pushProvider(workInProgress),
|
||||||
|
@ -3645,11 +3534,19 @@ function ReactFiberBeginWork(
|
||||||
shouldDeprioritizeSubtree = config.shouldDeprioritizeSubtree,
|
shouldDeprioritizeSubtree = config.shouldDeprioritizeSubtree,
|
||||||
pushHostContext = hostContext.pushHostContext,
|
pushHostContext = hostContext.pushHostContext,
|
||||||
pushHostContainer = hostContext.pushHostContainer,
|
pushHostContainer = hostContext.pushHostContainer,
|
||||||
|
pushProvider = newContext.pushProvider,
|
||||||
|
getMaskedContext = legacyContext.getMaskedContext,
|
||||||
|
getUnmaskedContext = legacyContext.getUnmaskedContext,
|
||||||
|
hasLegacyContextChanged = legacyContext.hasContextChanged,
|
||||||
|
pushLegacyContextProvider = legacyContext.pushContextProvider,
|
||||||
|
pushTopLevelContextObject = legacyContext.pushTopLevelContextObject,
|
||||||
|
invalidateContextProvider = legacyContext.invalidateContextProvider,
|
||||||
enterHydrationState = hydrationContext.enterHydrationState,
|
enterHydrationState = hydrationContext.enterHydrationState,
|
||||||
resetHydrationState = hydrationContext.resetHydrationState,
|
resetHydrationState = hydrationContext.resetHydrationState,
|
||||||
tryToClaimNextHydratableInstance =
|
tryToClaimNextHydratableInstance =
|
||||||
hydrationContext.tryToClaimNextHydratableInstance;
|
hydrationContext.tryToClaimNextHydratableInstance;
|
||||||
config = ReactFiberClassComponent(
|
config = ReactFiberClassComponent(
|
||||||
|
legacyContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
computeExpirationForFiber,
|
computeExpirationForFiber,
|
||||||
function(workInProgress, nextProps) {
|
function(workInProgress, nextProps) {
|
||||||
|
@ -3676,7 +3573,7 @@ function ReactFiberBeginWork(
|
||||||
pushHostRootContext(workInProgress);
|
pushHostRootContext(workInProgress);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
pushContextProvider(workInProgress);
|
pushLegacyContextProvider(workInProgress);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
pushHostContainer(
|
pushHostContainer(
|
||||||
|
@ -3722,7 +3619,7 @@ function ReactFiberBeginWork(
|
||||||
workInProgress.memoizedState,
|
workInProgress.memoizedState,
|
||||||
props
|
props
|
||||||
))),
|
))),
|
||||||
(props = pushContextProvider(workInProgress)),
|
(props = pushLegacyContextProvider(workInProgress)),
|
||||||
adoptClassInstance(workInProgress, fn),
|
adoptClassInstance(workInProgress, fn),
|
||||||
mountClassInstance(workInProgress, renderExpirationTime),
|
mountClassInstance(workInProgress, renderExpirationTime),
|
||||||
(current = finishClassComponent(
|
(current = finishClassComponent(
|
||||||
|
@ -3742,7 +3639,7 @@ function ReactFiberBeginWork(
|
||||||
return (
|
return (
|
||||||
(props = workInProgress.type),
|
(props = workInProgress.type),
|
||||||
(renderExpirationTime = workInProgress.pendingProps),
|
(renderExpirationTime = workInProgress.pendingProps),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
workInProgress.memoizedProps !== renderExpirationTime
|
workInProgress.memoizedProps !== renderExpirationTime
|
||||||
? ((fn = getUnmaskedContext(workInProgress)),
|
? ((fn = getUnmaskedContext(workInProgress)),
|
||||||
(fn = getMaskedContext(workInProgress, fn)),
|
(fn = getMaskedContext(workInProgress, fn)),
|
||||||
|
@ -3758,7 +3655,7 @@ function ReactFiberBeginWork(
|
||||||
current
|
current
|
||||||
);
|
);
|
||||||
case 2:
|
case 2:
|
||||||
props = pushContextProvider(workInProgress);
|
props = pushLegacyContextProvider(workInProgress);
|
||||||
null === current
|
null === current
|
||||||
? null === workInProgress.stateNode
|
? null === workInProgress.stateNode
|
||||||
? (constructClassInstance(
|
? (constructClassInstance(
|
||||||
|
@ -3840,7 +3737,7 @@ function ReactFiberBeginWork(
|
||||||
updateQueue = workInProgress.memoizedProps;
|
updateQueue = workInProgress.memoizedProps;
|
||||||
fn = workInProgress.pendingProps;
|
fn = workInProgress.pendingProps;
|
||||||
unmaskedContext = null !== current ? current.memoizedProps : null;
|
unmaskedContext = null !== current ? current.memoizedProps : null;
|
||||||
if (!didPerformWorkStackCursor.current && updateQueue === fn) {
|
if (!hasLegacyContextChanged() && updateQueue === fn) {
|
||||||
if (
|
if (
|
||||||
(updateQueue =
|
(updateQueue =
|
||||||
workInProgress.mode & 1 &&
|
workInProgress.mode & 1 &&
|
||||||
|
@ -3882,7 +3779,7 @@ function ReactFiberBeginWork(
|
||||||
case 7:
|
case 7:
|
||||||
return (
|
return (
|
||||||
(props = workInProgress.pendingProps),
|
(props = workInProgress.pendingProps),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
workInProgress.memoizedProps !== props ||
|
workInProgress.memoizedProps !== props ||
|
||||||
(props = workInProgress.memoizedProps),
|
(props = workInProgress.memoizedProps),
|
||||||
(fn = props.children),
|
(fn = props.children),
|
||||||
|
@ -3912,8 +3809,7 @@ function ReactFiberBeginWork(
|
||||||
workInProgress.stateNode.containerInfo
|
workInProgress.stateNode.containerInfo
|
||||||
),
|
),
|
||||||
(props = workInProgress.pendingProps),
|
(props = workInProgress.pendingProps),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() || workInProgress.memoizedProps !== props
|
||||||
workInProgress.memoizedProps !== props
|
|
||||||
? (null === current
|
? (null === current
|
||||||
? (workInProgress.child = reconcileChildFibers(
|
? (workInProgress.child = reconcileChildFibers(
|
||||||
workInProgress,
|
workInProgress,
|
||||||
|
@ -3944,7 +3840,7 @@ function ReactFiberBeginWork(
|
||||||
case 10:
|
case 10:
|
||||||
return (
|
return (
|
||||||
(renderExpirationTime = workInProgress.pendingProps),
|
(renderExpirationTime = workInProgress.pendingProps),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
workInProgress.memoizedProps !== renderExpirationTime
|
workInProgress.memoizedProps !== renderExpirationTime
|
||||||
? (reconcileChildren(
|
? (reconcileChildren(
|
||||||
current,
|
current,
|
||||||
|
@ -3962,7 +3858,7 @@ function ReactFiberBeginWork(
|
||||||
case 11:
|
case 11:
|
||||||
return (
|
return (
|
||||||
(renderExpirationTime = workInProgress.pendingProps.children),
|
(renderExpirationTime = workInProgress.pendingProps.children),
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
(null !== renderExpirationTime &&
|
(null !== renderExpirationTime &&
|
||||||
workInProgress.memoizedProps !== renderExpirationTime)
|
workInProgress.memoizedProps !== renderExpirationTime)
|
||||||
? (reconcileChildren(
|
? (reconcileChildren(
|
||||||
|
@ -3992,7 +3888,7 @@ function ReactFiberBeginWork(
|
||||||
props = fn._currentValue;
|
props = fn._currentValue;
|
||||||
var changedBits = fn._changedBits;
|
var changedBits = fn._changedBits;
|
||||||
if (
|
if (
|
||||||
didPerformWorkStackCursor.current ||
|
hasLegacyContextChanged() ||
|
||||||
0 !== changedBits ||
|
0 !== changedBits ||
|
||||||
updateQueue !== unmaskedContext
|
updateQueue !== unmaskedContext
|
||||||
) {
|
) {
|
||||||
|
@ -4032,7 +3928,13 @@ function ReactFiberBeginWork(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
function ReactFiberCompleteWork(
|
||||||
|
config,
|
||||||
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
newContext,
|
||||||
|
hydrationContext
|
||||||
|
) {
|
||||||
function markUpdate(workInProgress) {
|
function markUpdate(workInProgress) {
|
||||||
workInProgress.effectTag |= 4;
|
workInProgress.effectTag |= 4;
|
||||||
}
|
}
|
||||||
|
@ -4046,6 +3948,9 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
||||||
popHostContext = hostContext.popHostContext,
|
popHostContext = hostContext.popHostContext,
|
||||||
getHostContext = hostContext.getHostContext,
|
getHostContext = hostContext.getHostContext,
|
||||||
popHostContainer = hostContext.popHostContainer,
|
popHostContainer = hostContext.popHostContainer,
|
||||||
|
popLegacyContextProvider = legacyContext.popContextProvider,
|
||||||
|
popTopLevelLegacyContextObject = legacyContext.popTopLevelContextObject,
|
||||||
|
popProvider = newContext.popProvider,
|
||||||
prepareToHydrateHostInstance =
|
prepareToHydrateHostInstance =
|
||||||
hydrationContext.prepareToHydrateHostInstance,
|
hydrationContext.prepareToHydrateHostInstance,
|
||||||
prepareToHydrateHostTextInstance =
|
prepareToHydrateHostTextInstance =
|
||||||
|
@ -4074,7 +3979,7 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
||||||
return null;
|
return null;
|
||||||
case 2:
|
case 2:
|
||||||
return (
|
return (
|
||||||
popContextProvider(workInProgress),
|
popLegacyContextProvider(workInProgress),
|
||||||
(current = workInProgress.stateNode),
|
(current = workInProgress.stateNode),
|
||||||
(newProps = workInProgress.updateQueue),
|
(newProps = workInProgress.updateQueue),
|
||||||
null !== newProps &&
|
null !== newProps &&
|
||||||
|
@ -4087,8 +3992,7 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
||||||
);
|
);
|
||||||
case 3:
|
case 3:
|
||||||
popHostContainer(workInProgress);
|
popHostContainer(workInProgress);
|
||||||
pop(didPerformWorkStackCursor, workInProgress);
|
popTopLevelLegacyContextObject(workInProgress);
|
||||||
pop(contextStackCursor, workInProgress);
|
|
||||||
newProps = workInProgress.stateNode;
|
newProps = workInProgress.stateNode;
|
||||||
newProps.pendingContext &&
|
newProps.pendingContext &&
|
||||||
((newProps.context = newProps.pendingContext),
|
((newProps.context = newProps.pendingContext),
|
||||||
|
@ -4304,11 +4208,16 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
|
||||||
}
|
}
|
||||||
function ReactFiberUnwindWork(
|
function ReactFiberUnwindWork(
|
||||||
hostContext,
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
newContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
isAlreadyFailedLegacyErrorBoundary
|
isAlreadyFailedLegacyErrorBoundary
|
||||||
) {
|
) {
|
||||||
var popHostContainer = hostContext.popHostContainer,
|
var popHostContainer = hostContext.popHostContainer,
|
||||||
popHostContext = hostContext.popHostContext;
|
popHostContext = hostContext.popHostContext,
|
||||||
|
popLegacyContextProvider = legacyContext.popContextProvider,
|
||||||
|
popTopLevelLegacyContextObject = legacyContext.popTopLevelContextObject,
|
||||||
|
popProvider = newContext.popProvider;
|
||||||
return {
|
return {
|
||||||
throwException: function(returnFiber, sourceFiber, rawValue) {
|
throwException: function(returnFiber, sourceFiber, rawValue) {
|
||||||
sourceFiber.effectTag |= 512;
|
sourceFiber.effectTag |= 512;
|
||||||
|
@ -4352,7 +4261,7 @@ function ReactFiberUnwindWork(
|
||||||
unwindWork: function(workInProgress) {
|
unwindWork: function(workInProgress) {
|
||||||
switch (workInProgress.tag) {
|
switch (workInProgress.tag) {
|
||||||
case 2:
|
case 2:
|
||||||
popContextProvider(workInProgress);
|
popLegacyContextProvider(workInProgress);
|
||||||
var effectTag = workInProgress.effectTag;
|
var effectTag = workInProgress.effectTag;
|
||||||
return effectTag & 1024
|
return effectTag & 1024
|
||||||
? ((workInProgress.effectTag = (effectTag & -1025) | 64),
|
? ((workInProgress.effectTag = (effectTag & -1025) | 64),
|
||||||
|
@ -4361,8 +4270,7 @@ function ReactFiberUnwindWork(
|
||||||
case 3:
|
case 3:
|
||||||
return (
|
return (
|
||||||
popHostContainer(workInProgress),
|
popHostContainer(workInProgress),
|
||||||
pop(didPerformWorkStackCursor, workInProgress),
|
popTopLevelLegacyContextObject(workInProgress),
|
||||||
pop(contextStackCursor, workInProgress),
|
|
||||||
(effectTag = workInProgress.effectTag),
|
(effectTag = workInProgress.effectTag),
|
||||||
effectTag & 1024
|
effectTag & 1024
|
||||||
? ((workInProgress.effectTag = (effectTag & -1025) | 64),
|
? ((workInProgress.effectTag = (effectTag & -1025) | 64),
|
||||||
|
@ -4378,6 +4286,25 @@ function ReactFiberUnwindWork(
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
unwindInterruptedWork: function(interruptedWork) {
|
||||||
|
switch (interruptedWork.tag) {
|
||||||
|
case 2:
|
||||||
|
popLegacyContextProvider(interruptedWork);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
popHostContainer(interruptedWork);
|
||||||
|
popTopLevelLegacyContextObject(interruptedWork);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
popHostContext(interruptedWork);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
popHostContainer(interruptedWork);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
popProvider(interruptedWork);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4819,7 +4746,7 @@ function ReactFiberCommitWork(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var NO_CONTEXT = {};
|
var NO_CONTEXT = {};
|
||||||
function ReactFiberHostContext(config) {
|
function ReactFiberHostContext(config, stack) {
|
||||||
function requiredContext(c) {
|
function requiredContext(c) {
|
||||||
invariant(
|
invariant(
|
||||||
c !== NO_CONTEXT,
|
c !== NO_CONTEXT,
|
||||||
|
@ -4828,10 +4755,13 @@ function ReactFiberHostContext(config) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
var getChildHostContext = config.getChildHostContext,
|
var getChildHostContext = config.getChildHostContext,
|
||||||
getRootHostContext = config.getRootHostContext,
|
getRootHostContext = config.getRootHostContext;
|
||||||
contextStackCursor = { current: NO_CONTEXT },
|
config = stack.createCursor;
|
||||||
contextFiberStackCursor = { current: NO_CONTEXT },
|
var push = stack.push,
|
||||||
rootInstanceStackCursor = { current: NO_CONTEXT };
|
pop = stack.pop,
|
||||||
|
contextStackCursor = config(NO_CONTEXT),
|
||||||
|
contextFiberStackCursor = config(NO_CONTEXT),
|
||||||
|
rootInstanceStackCursor = config(NO_CONTEXT);
|
||||||
return {
|
return {
|
||||||
getHostContext: function() {
|
getHostContext: function() {
|
||||||
return requiredContext(contextStackCursor.current);
|
return requiredContext(contextStackCursor.current);
|
||||||
|
@ -4861,10 +4791,6 @@ function ReactFiberHostContext(config) {
|
||||||
context !== rootInstance &&
|
context !== rootInstance &&
|
||||||
(push(contextFiberStackCursor, fiber, fiber),
|
(push(contextFiberStackCursor, fiber, fiber),
|
||||||
push(contextStackCursor, rootInstance, fiber));
|
push(contextStackCursor, rootInstance, fiber));
|
||||||
},
|
|
||||||
resetHostContainer: function() {
|
|
||||||
contextStackCursor.current = NO_CONTEXT;
|
|
||||||
rootInstanceStackCursor.current = NO_CONTEXT;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -5024,22 +4950,198 @@ function ReactFiberHydrationContext(config) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ReactFiberScheduler(config) {
|
function ReactFiberLegacyContext(stack) {
|
||||||
function resetContextStack() {
|
function cacheContext(workInProgress, unmaskedContext, maskedContext) {
|
||||||
for (; -1 < index; ) (valueStack[index] = null), index--;
|
workInProgress = workInProgress.stateNode;
|
||||||
|
workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
|
||||||
|
workInProgress.__reactInternalMemoizedMaskedChildContext = maskedContext;
|
||||||
|
}
|
||||||
|
function isContextProvider(fiber) {
|
||||||
|
return 2 === fiber.tag && null != fiber.type.childContextTypes;
|
||||||
|
}
|
||||||
|
function processChildContext(fiber, parentContext) {
|
||||||
|
var instance = fiber.stateNode,
|
||||||
|
childContextTypes = fiber.type.childContextTypes;
|
||||||
|
if ("function" !== typeof instance.getChildContext) return parentContext;
|
||||||
|
instance = instance.getChildContext();
|
||||||
|
for (var contextKey in instance)
|
||||||
|
invariant(
|
||||||
|
contextKey in childContextTypes,
|
||||||
|
'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
|
||||||
|
getComponentName(fiber) || "Unknown",
|
||||||
|
contextKey
|
||||||
|
);
|
||||||
|
return Object.assign({}, parentContext, instance);
|
||||||
|
}
|
||||||
|
var createCursor = stack.createCursor,
|
||||||
|
push = stack.push,
|
||||||
|
pop = stack.pop,
|
||||||
|
contextStackCursor = createCursor(emptyObject),
|
||||||
|
didPerformWorkStackCursor = createCursor(!1),
|
||||||
previousContext = emptyObject;
|
previousContext = emptyObject;
|
||||||
contextStackCursor.current = emptyObject;
|
return {
|
||||||
didPerformWorkStackCursor.current = !1;
|
getUnmaskedContext: function(workInProgress) {
|
||||||
resetHostContainer();
|
return isContextProvider(workInProgress)
|
||||||
for (var i = index$1; -1 < i; i--) {
|
? previousContext
|
||||||
var context = stack[i].type.context;
|
: contextStackCursor.current;
|
||||||
context._currentValue = context._defaultValue;
|
},
|
||||||
context._changedBits = 0;
|
cacheContext: cacheContext,
|
||||||
changedBitsStack[i] = null;
|
getMaskedContext: function(workInProgress, unmaskedContext) {
|
||||||
currentValueStack[i] = null;
|
var contextTypes = workInProgress.type.contextTypes;
|
||||||
stack[i] = null;
|
if (!contextTypes) return emptyObject;
|
||||||
|
var instance = workInProgress.stateNode;
|
||||||
|
if (
|
||||||
|
instance &&
|
||||||
|
instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext
|
||||||
|
)
|
||||||
|
return instance.__reactInternalMemoizedMaskedChildContext;
|
||||||
|
var context = {},
|
||||||
|
key;
|
||||||
|
for (key in contextTypes) context[key] = unmaskedContext[key];
|
||||||
|
instance && cacheContext(workInProgress, unmaskedContext, context);
|
||||||
|
return context;
|
||||||
|
},
|
||||||
|
hasContextChanged: function() {
|
||||||
|
return didPerformWorkStackCursor.current;
|
||||||
|
},
|
||||||
|
isContextConsumer: function(fiber) {
|
||||||
|
return 2 === fiber.tag && null != fiber.type.contextTypes;
|
||||||
|
},
|
||||||
|
isContextProvider: isContextProvider,
|
||||||
|
popContextProvider: function(fiber) {
|
||||||
|
isContextProvider(fiber) &&
|
||||||
|
(pop(didPerformWorkStackCursor, fiber), pop(contextStackCursor, fiber));
|
||||||
|
},
|
||||||
|
popTopLevelContextObject: function(fiber) {
|
||||||
|
pop(didPerformWorkStackCursor, fiber);
|
||||||
|
pop(contextStackCursor, fiber);
|
||||||
|
},
|
||||||
|
pushTopLevelContextObject: function(fiber, context, didChange) {
|
||||||
|
invariant(
|
||||||
|
null == contextStackCursor.cursor,
|
||||||
|
"Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."
|
||||||
|
);
|
||||||
|
push(contextStackCursor, context, fiber);
|
||||||
|
push(didPerformWorkStackCursor, didChange, fiber);
|
||||||
|
},
|
||||||
|
processChildContext: processChildContext,
|
||||||
|
pushContextProvider: function(workInProgress) {
|
||||||
|
if (!isContextProvider(workInProgress)) return !1;
|
||||||
|
var instance = workInProgress.stateNode;
|
||||||
|
instance =
|
||||||
|
(instance && instance.__reactInternalMemoizedMergedChildContext) ||
|
||||||
|
emptyObject;
|
||||||
|
previousContext = contextStackCursor.current;
|
||||||
|
push(contextStackCursor, instance, workInProgress);
|
||||||
|
push(
|
||||||
|
didPerformWorkStackCursor,
|
||||||
|
didPerformWorkStackCursor.current,
|
||||||
|
workInProgress
|
||||||
|
);
|
||||||
|
return !0;
|
||||||
|
},
|
||||||
|
invalidateContextProvider: function(workInProgress, didChange) {
|
||||||
|
var instance = workInProgress.stateNode;
|
||||||
|
invariant(
|
||||||
|
instance,
|
||||||
|
"Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."
|
||||||
|
);
|
||||||
|
if (didChange) {
|
||||||
|
var mergedContext = processChildContext(
|
||||||
|
workInProgress,
|
||||||
|
previousContext
|
||||||
|
);
|
||||||
|
instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
||||||
|
pop(didPerformWorkStackCursor, workInProgress);
|
||||||
|
pop(contextStackCursor, workInProgress);
|
||||||
|
push(contextStackCursor, mergedContext, workInProgress);
|
||||||
|
} else pop(didPerformWorkStackCursor, workInProgress);
|
||||||
|
push(didPerformWorkStackCursor, didChange, workInProgress);
|
||||||
|
},
|
||||||
|
findCurrentUnmaskedContext: function(fiber) {
|
||||||
|
for (
|
||||||
|
invariant(
|
||||||
|
2 === isFiberMountedImpl(fiber) && 2 === fiber.tag,
|
||||||
|
"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."
|
||||||
|
);
|
||||||
|
3 !== fiber.tag;
|
||||||
|
|
||||||
|
) {
|
||||||
|
if (isContextProvider(fiber))
|
||||||
|
return fiber.stateNode.__reactInternalMemoizedMergedChildContext;
|
||||||
|
fiber = fiber["return"];
|
||||||
|
invariant(
|
||||||
|
fiber,
|
||||||
|
"Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return fiber.stateNode.context;
|
||||||
}
|
}
|
||||||
index$1 = -1;
|
};
|
||||||
|
}
|
||||||
|
function ReactFiberNewContext(stack) {
|
||||||
|
var createCursor = stack.createCursor,
|
||||||
|
push = stack.push,
|
||||||
|
pop = stack.pop,
|
||||||
|
providerCursor = createCursor(null),
|
||||||
|
valueCursor = createCursor(null),
|
||||||
|
changedBitsCursor = createCursor(0);
|
||||||
|
return {
|
||||||
|
pushProvider: function(providerFiber) {
|
||||||
|
var context = providerFiber.type.context;
|
||||||
|
push(changedBitsCursor, context._changedBits, providerFiber);
|
||||||
|
push(valueCursor, context._currentValue, providerFiber);
|
||||||
|
push(providerCursor, providerFiber, providerFiber);
|
||||||
|
context._currentValue = providerFiber.pendingProps.value;
|
||||||
|
context._changedBits = providerFiber.stateNode;
|
||||||
|
},
|
||||||
|
popProvider: function(providerFiber) {
|
||||||
|
var changedBits = changedBitsCursor.current,
|
||||||
|
currentValue = valueCursor.current;
|
||||||
|
pop(providerCursor, providerFiber);
|
||||||
|
pop(valueCursor, providerFiber);
|
||||||
|
pop(changedBitsCursor, providerFiber);
|
||||||
|
providerFiber = providerFiber.type.context;
|
||||||
|
providerFiber._currentValue = currentValue;
|
||||||
|
providerFiber._changedBits = changedBits;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function ReactFiberStack() {
|
||||||
|
var valueStack = [],
|
||||||
|
index = -1;
|
||||||
|
return {
|
||||||
|
createCursor: function(defaultValue) {
|
||||||
|
return { current: defaultValue };
|
||||||
|
},
|
||||||
|
isEmpty: function() {
|
||||||
|
return -1 === index;
|
||||||
|
},
|
||||||
|
pop: function(cursor) {
|
||||||
|
0 > index ||
|
||||||
|
((cursor.current = valueStack[index]),
|
||||||
|
(valueStack[index] = null),
|
||||||
|
index--);
|
||||||
|
},
|
||||||
|
push: function(cursor, value) {
|
||||||
|
index++;
|
||||||
|
valueStack[index] = cursor.current;
|
||||||
|
cursor.current = value;
|
||||||
|
},
|
||||||
|
checkThatStackIsEmpty: function() {},
|
||||||
|
resetStackAfterFatalErrorInDev: function() {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function ReactFiberScheduler(config) {
|
||||||
|
function resetStack() {
|
||||||
|
if (null !== nextUnitOfWork)
|
||||||
|
for (
|
||||||
|
var interruptedWork = nextUnitOfWork["return"];
|
||||||
|
null !== interruptedWork;
|
||||||
|
|
||||||
|
)
|
||||||
|
unwindInterruptedWork(interruptedWork),
|
||||||
|
(interruptedWork = interruptedWork["return"]);
|
||||||
nextRoot = null;
|
nextRoot = null;
|
||||||
nextRenderExpirationTime = 0;
|
nextRenderExpirationTime = 0;
|
||||||
nextUnitOfWork = null;
|
nextUnitOfWork = null;
|
||||||
|
@ -5145,7 +5247,7 @@ function ReactFiberScheduler(config) {
|
||||||
root !== nextRoot ||
|
root !== nextRoot ||
|
||||||
null === nextUnitOfWork
|
null === nextUnitOfWork
|
||||||
)
|
)
|
||||||
resetContextStack(),
|
resetStack(),
|
||||||
(nextRoot = root),
|
(nextRoot = root),
|
||||||
(nextRenderExpirationTime = expirationTime),
|
(nextRenderExpirationTime = expirationTime),
|
||||||
(nextUnitOfWork = createWorkInProgress(
|
(nextUnitOfWork = createWorkInProgress(
|
||||||
|
@ -5275,7 +5377,7 @@ function ReactFiberScheduler(config) {
|
||||||
!isWorking &&
|
!isWorking &&
|
||||||
0 !== nextRenderExpirationTime &&
|
0 !== nextRenderExpirationTime &&
|
||||||
expirationTime < nextRenderExpirationTime &&
|
expirationTime < nextRenderExpirationTime &&
|
||||||
resetContextStack();
|
resetStack();
|
||||||
(nextRoot === root && isWorking) ||
|
(nextRoot === root && isWorking) ||
|
||||||
requestWork(root, expirationTime);
|
requestWork(root, expirationTime);
|
||||||
nestedUpdateCount > NESTED_UPDATE_LIMIT &&
|
nestedUpdateCount > NESTED_UPDATE_LIMIT &&
|
||||||
|
@ -5619,25 +5721,37 @@ function ReactFiberScheduler(config) {
|
||||||
nextFlushedRoot.remainingExpirationTime = 0;
|
nextFlushedRoot.remainingExpirationTime = 0;
|
||||||
hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error));
|
hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error));
|
||||||
}
|
}
|
||||||
var hostContext = ReactFiberHostContext(config),
|
var stack = ReactFiberStack(),
|
||||||
hydrationContext = ReactFiberHydrationContext(config),
|
hostContext = ReactFiberHostContext(config, stack),
|
||||||
resetHostContainer = hostContext.resetHostContainer,
|
legacyContext = ReactFiberLegacyContext(stack);
|
||||||
|
stack = ReactFiberNewContext(stack);
|
||||||
|
var hydrationContext = ReactFiberHydrationContext(config),
|
||||||
beginWork = ReactFiberBeginWork(
|
beginWork = ReactFiberBeginWork(
|
||||||
config,
|
config,
|
||||||
hostContext,
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
stack,
|
||||||
hydrationContext,
|
hydrationContext,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
computeExpirationForFiber
|
computeExpirationForFiber
|
||||||
).beginWork,
|
).beginWork,
|
||||||
completeWork = ReactFiberCompleteWork(config, hostContext, hydrationContext)
|
completeWork = ReactFiberCompleteWork(
|
||||||
.completeWork;
|
config,
|
||||||
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
stack,
|
||||||
|
hydrationContext
|
||||||
|
).completeWork;
|
||||||
hostContext = ReactFiberUnwindWork(
|
hostContext = ReactFiberUnwindWork(
|
||||||
hostContext,
|
hostContext,
|
||||||
|
legacyContext,
|
||||||
|
stack,
|
||||||
scheduleWork,
|
scheduleWork,
|
||||||
isAlreadyFailedLegacyErrorBoundary
|
isAlreadyFailedLegacyErrorBoundary
|
||||||
);
|
);
|
||||||
var throwException = hostContext.throwException,
|
var throwException = hostContext.throwException,
|
||||||
unwindWork = hostContext.unwindWork;
|
unwindWork = hostContext.unwindWork,
|
||||||
|
unwindInterruptedWork = hostContext.unwindInterruptedWork;
|
||||||
hostContext = ReactFiberCommitWork(
|
hostContext = ReactFiberCommitWork(
|
||||||
config,
|
config,
|
||||||
onCommitPhaseError,
|
onCommitPhaseError,
|
||||||
|
@ -5796,7 +5910,8 @@ function ReactFiberScheduler(config) {
|
||||||
result <= lastUniqueAsyncExpiration &&
|
result <= lastUniqueAsyncExpiration &&
|
||||||
(result = lastUniqueAsyncExpiration + 1);
|
(result = lastUniqueAsyncExpiration + 1);
|
||||||
return (lastUniqueAsyncExpiration = result);
|
return (lastUniqueAsyncExpiration = result);
|
||||||
}
|
},
|
||||||
|
legacyContext: legacyContext
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function ReactFiberReconciler$1(config) {
|
function ReactFiberReconciler$1(config) {
|
||||||
|
@ -5811,27 +5926,7 @@ function ReactFiberReconciler$1(config) {
|
||||||
currentTime = container.current;
|
currentTime = container.current;
|
||||||
if (parentComponent) {
|
if (parentComponent) {
|
||||||
parentComponent = parentComponent._reactInternalFiber;
|
parentComponent = parentComponent._reactInternalFiber;
|
||||||
var parentContext;
|
var parentContext = findCurrentUnmaskedContext(parentComponent);
|
||||||
b: {
|
|
||||||
invariant(
|
|
||||||
2 === isFiberMountedImpl(parentComponent) &&
|
|
||||||
2 === parentComponent.tag,
|
|
||||||
"Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."
|
|
||||||
);
|
|
||||||
for (parentContext = parentComponent; 3 !== parentContext.tag; ) {
|
|
||||||
if (isContextProvider(parentContext)) {
|
|
||||||
parentContext =
|
|
||||||
parentContext.stateNode.__reactInternalMemoizedMergedChildContext;
|
|
||||||
break b;
|
|
||||||
}
|
|
||||||
parentContext = parentContext["return"];
|
|
||||||
invariant(
|
|
||||||
parentContext,
|
|
||||||
"Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
parentContext = parentContext.stateNode.context;
|
|
||||||
}
|
|
||||||
parentComponent = isContextProvider(parentComponent)
|
parentComponent = isContextProvider(parentComponent)
|
||||||
? processChildContext(parentComponent, parentContext)
|
? processChildContext(parentComponent, parentContext)
|
||||||
: parentContext;
|
: parentContext;
|
||||||
|
@ -5860,7 +5955,11 @@ function ReactFiberReconciler$1(config) {
|
||||||
config = ReactFiberScheduler(config);
|
config = ReactFiberScheduler(config);
|
||||||
var recalculateCurrentTime = config.recalculateCurrentTime,
|
var recalculateCurrentTime = config.recalculateCurrentTime,
|
||||||
computeExpirationForFiber = config.computeExpirationForFiber,
|
computeExpirationForFiber = config.computeExpirationForFiber,
|
||||||
scheduleWork = config.scheduleWork;
|
scheduleWork = config.scheduleWork,
|
||||||
|
legacyContext = config.legacyContext,
|
||||||
|
findCurrentUnmaskedContext = legacyContext.findCurrentUnmaskedContext,
|
||||||
|
isContextProvider = legacyContext.isContextProvider,
|
||||||
|
processChildContext = legacyContext.processChildContext;
|
||||||
return {
|
return {
|
||||||
createContainer: function(containerInfo, isAsync, hydrate) {
|
createContainer: function(containerInfo, isAsync, hydrate) {
|
||||||
isAsync = new FiberNode(3, null, null, isAsync ? 3 : 0);
|
isAsync = new FiberNode(3, null, null, isAsync ? 3 : 0);
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const BatchedBridge = require('BatchedBridge');
|
||||||
|
|
||||||
// TODO @sema: Adjust types
|
// TODO @sema: Adjust types
|
||||||
import type {ReactNativeType} from 'ReactNativeTypes';
|
import type {ReactNativeType} from 'ReactNativeTypes';
|
||||||
|
|
||||||
|
@ -20,4 +22,7 @@ if (__DEV__) {
|
||||||
ReactFabric = require('ReactFabric-prod');
|
ReactFabric = require('ReactFabric-prod');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BatchedBridge.registerCallableModule('ReactFabric', ReactFabric);
|
||||||
|
|
||||||
module.exports = (ReactFabric: ReactNativeType);
|
module.exports = (ReactFabric: ReactNativeType);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue