mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Rename HostContainer => HostRoot, Portal => HostPortal (#8474)
This commit is contained in:
1 parent
7cd26024ce
commit
df9dc89333
12 files changed
+58
-58
No files matched your search
@@ -21,7 +21,7 @@ var ReactTypeOfWork = require('ReactTypeOfWork');
|
||||
var getEventTarget = require('getEventTarget');
|
||||
var getUnboundedScrollPosition = require('getUnboundedScrollPosition');
|
||||
|
||||
var { HostContainer } = ReactTypeOfWork;
|
||||
var { HostRoot } = ReactTypeOfWork;
|
||||
|
||||
/**
|
||||
* Find the deepest React component completely containing the root of the
|
||||
@@ -36,7 +36,7 @@ function findRootContainerNode(inst) {
|
||||
while (inst.return) {
|
||||
inst = inst.return;
|
||||
}
|
||||
if (inst.tag !== HostContainer) {
|
||||
if (inst.tag !== HostRoot) {
|
||||
// This can happen if we're in a detached tree.
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -56,10 +56,10 @@ const isArray = Array.isArray;
|
||||
const {
|
||||
ClassComponent,
|
||||
HostText,
|
||||
HostPortal,
|
||||
CoroutineComponent,
|
||||
YieldComponent,
|
||||
Fragment,
|
||||
Portal,
|
||||
} = ReactTypeOfWork;
|
||||
|
||||
const {
|
||||
@@ -330,7 +330,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
|
||||
) : Fiber {
|
||||
if (
|
||||
current == null ||
|
||||
current.tag !== Portal ||
|
||||
current.tag !== HostPortal ||
|
||||
current.stateNode.containerInfo !== portal.containerInfo ||
|
||||
current.stateNode.implementation !== portal.implementation
|
||||
) {
|
||||
@@ -970,7 +970,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
|
||||
// the first item in the list.
|
||||
if (child.key === key) {
|
||||
if (
|
||||
child.tag === Portal &&
|
||||
child.tag === HostPortal &&
|
||||
child.stateNode.containerInfo === portal.containerInfo &&
|
||||
child.stateNode.implementation === portal.implementation
|
||||
) {
|
||||
|
||||
@@ -24,13 +24,13 @@ var ReactTypeOfWork = require('ReactTypeOfWork');
|
||||
var {
|
||||
IndeterminateComponent,
|
||||
ClassComponent,
|
||||
HostContainer,
|
||||
HostRoot,
|
||||
HostComponent,
|
||||
HostText,
|
||||
HostPortal,
|
||||
CoroutineComponent,
|
||||
YieldComponent,
|
||||
Fragment,
|
||||
Portal,
|
||||
} = ReactTypeOfWork;
|
||||
|
||||
var {
|
||||
@@ -269,8 +269,8 @@ exports.cloneFiber = function(fiber : Fiber, priorityLevel : PriorityLevel) : Fi
|
||||
return alt;
|
||||
};
|
||||
|
||||
exports.createHostContainerFiber = function() : Fiber {
|
||||
const fiber = createFiber(HostContainer, null);
|
||||
exports.createHostRootFiber = function() : Fiber {
|
||||
const fiber = createFiber(HostRoot, null);
|
||||
return fiber;
|
||||
};
|
||||
|
||||
@@ -345,7 +345,7 @@ exports.createFiberFromYield = function(yieldNode : ReactYield, priorityLevel :
|
||||
};
|
||||
|
||||
exports.createFiberFromPortal = function(portal : ReactPortal, priorityLevel : PriorityLevel) : Fiber {
|
||||
const fiber = createFiber(Portal, portal.key);
|
||||
const fiber = createFiber(HostPortal, portal.key);
|
||||
fiber.pendingProps = portal.children;
|
||||
fiber.pendingWorkPriority = priorityLevel;
|
||||
fiber.stateNode = {
|
||||
|
||||
@@ -38,14 +38,14 @@ var {
|
||||
IndeterminateComponent,
|
||||
FunctionalComponent,
|
||||
ClassComponent,
|
||||
HostContainer,
|
||||
HostRoot,
|
||||
HostComponent,
|
||||
HostText,
|
||||
HostPortal,
|
||||
CoroutineComponent,
|
||||
CoroutineHandlerPhase,
|
||||
YieldComponent,
|
||||
Fragment,
|
||||
Portal,
|
||||
} = ReactTypeOfWork;
|
||||
var {
|
||||
NoWork,
|
||||
@@ -449,7 +449,7 @@ module.exports = function<T, P, I, TI, C>(
|
||||
return updateFunctionalComponent(current, workInProgress);
|
||||
case ClassComponent:
|
||||
return updateClassComponent(current, workInProgress);
|
||||
case HostContainer: {
|
||||
case HostRoot: {
|
||||
const root = (workInProgress.stateNode : FiberRoot);
|
||||
if (root.pendingContext) {
|
||||
pushTopLevelContextObject(
|
||||
@@ -483,7 +483,7 @@ module.exports = function<T, P, I, TI, C>(
|
||||
// A yield component is just a placeholder, we can just run through the
|
||||
// next one immediately.
|
||||
return null;
|
||||
case Portal:
|
||||
case HostPortal:
|
||||
updatePortalComponent(current, workInProgress);
|
||||
// TODO: is this right?
|
||||
return workInProgress.child;
|
||||
@@ -497,7 +497,7 @@ module.exports = function<T, P, I, TI, C>(
|
||||
|
||||
function beginFailedWork(current : ?Fiber, workInProgress : Fiber, priorityLevel : PriorityLevel) {
|
||||
if (workInProgress.tag !== ClassComponent &&
|
||||
workInProgress.tag !== HostContainer) {
|
||||
workInProgress.tag !== HostRoot) {
|
||||
throw new Error('Invalid type of work');
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ import type { HostConfig } from 'ReactFiberReconciler';
|
||||
var ReactTypeOfWork = require('ReactTypeOfWork');
|
||||
var {
|
||||
ClassComponent,
|
||||
HostContainer,
|
||||
HostRoot,
|
||||
HostComponent,
|
||||
HostText,
|
||||
HostPortal,
|
||||
CoroutineComponent,
|
||||
Portal,
|
||||
} = ReactTypeOfWork;
|
||||
var { callCallbacks } = require('ReactFiberUpdateQueue');
|
||||
|
||||
@@ -75,9 +75,9 @@ module.exports = function<T, P, I, TI, C>(
|
||||
switch (parent.tag) {
|
||||
case HostComponent:
|
||||
return parent.stateNode;
|
||||
case HostContainer:
|
||||
case HostRoot:
|
||||
return parent.stateNode.containerInfo;
|
||||
case Portal:
|
||||
case HostPortal:
|
||||
return parent.stateNode.containerInfo;
|
||||
}
|
||||
parent = parent.return;
|
||||
@@ -99,8 +99,8 @@ module.exports = function<T, P, I, TI, C>(
|
||||
function isHostParent(fiber : Fiber) : boolean {
|
||||
return (
|
||||
fiber.tag === HostComponent ||
|
||||
fiber.tag === HostContainer ||
|
||||
fiber.tag === Portal
|
||||
fiber.tag === HostRoot ||
|
||||
fiber.tag === HostPortal
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,10 +153,10 @@ module.exports = function<T, P, I, TI, C>(
|
||||
case HostComponent:
|
||||
parent = parentFiber.stateNode;
|
||||
break;
|
||||
case HostContainer:
|
||||
case HostRoot:
|
||||
parent = parentFiber.stateNode.containerInfo;
|
||||
break;
|
||||
case Portal:
|
||||
case HostPortal:
|
||||
parent = parentFiber.stateNode.containerInfo;
|
||||
break;
|
||||
default:
|
||||
@@ -180,7 +180,7 @@ module.exports = function<T, P, I, TI, C>(
|
||||
} else {
|
||||
appendChild(parent, node.stateNode);
|
||||
}
|
||||
} else if (node.tag === Portal) {
|
||||
} else if (node.tag === HostPortal) {
|
||||
// If the insertion itself is a portal, then we don't want to traverse
|
||||
// down its children. Instead, we'll get insertions from each child in
|
||||
// the portal directly.
|
||||
@@ -243,7 +243,7 @@ module.exports = function<T, P, I, TI, C>(
|
||||
// After all the children have unmounted, it is now safe to remove the
|
||||
// node from the tree.
|
||||
removeChild(parent, node.stateNode);
|
||||
} else if (node.tag === Portal) {
|
||||
} else if (node.tag === HostPortal) {
|
||||
// When we go into a portal, it becomes the parent to remove from.
|
||||
// We will reassign it back when we pop the portal on the way up.
|
||||
parent = node.stateNode.containerInfo;
|
||||
@@ -268,7 +268,7 @@ module.exports = function<T, P, I, TI, C>(
|
||||
return;
|
||||
}
|
||||
node = node.return;
|
||||
if (node.tag === Portal) {
|
||||
if (node.tag === HostPortal) {
|
||||
// When we go out of the portal, we need to restore the parent.
|
||||
// Since we don't keep a stack of them, we will search for it.
|
||||
parent = getHostParent(node);
|
||||
@@ -319,7 +319,7 @@ module.exports = function<T, P, I, TI, C>(
|
||||
commitNestedUnmounts(current.stateNode);
|
||||
return;
|
||||
}
|
||||
case Portal: {
|
||||
case HostPortal: {
|
||||
// TODO: this is recursive.
|
||||
commitDeletion(current);
|
||||
return;
|
||||
@@ -354,10 +354,10 @@ module.exports = function<T, P, I, TI, C>(
|
||||
commitTextUpdate(textInstance, oldText, newText);
|
||||
return;
|
||||
}
|
||||
case HostContainer: {
|
||||
case HostRoot: {
|
||||
return;
|
||||
}
|
||||
case Portal: {
|
||||
case HostPortal: {
|
||||
return;
|
||||
}
|
||||
default:
|
||||
@@ -400,7 +400,7 @@ module.exports = function<T, P, I, TI, C>(
|
||||
}
|
||||
return;
|
||||
}
|
||||
case HostContainer: {
|
||||
case HostRoot: {
|
||||
const rootFiber = finishedWork.stateNode;
|
||||
let firstError = null;
|
||||
if (rootFiber.callbackList) {
|
||||
@@ -422,7 +422,7 @@ module.exports = function<T, P, I, TI, C>(
|
||||
// We have no life-cycles associated with text.
|
||||
return;
|
||||
}
|
||||
case Portal: {
|
||||
case HostPortal: {
|
||||
// We have no life-cycles associated with portals.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ var {
|
||||
IndeterminateComponent,
|
||||
FunctionalComponent,
|
||||
ClassComponent,
|
||||
HostContainer,
|
||||
HostRoot,
|
||||
HostComponent,
|
||||
HostText,
|
||||
HostPortal,
|
||||
CoroutineComponent,
|
||||
CoroutineHandlerPhase,
|
||||
YieldComponent,
|
||||
Fragment,
|
||||
Portal,
|
||||
} = ReactTypeOfWork;
|
||||
var {
|
||||
Update,
|
||||
@@ -66,7 +66,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
let node = workInProgress.child;
|
||||
while (node) {
|
||||
if (node.tag === HostComponent || node.tag === HostText ||
|
||||
node.tag === Portal) {
|
||||
node.tag === HostPortal) {
|
||||
throw new Error('A coroutine cannot have host component children.');
|
||||
} else if (node.tag === YieldComponent) {
|
||||
yields.push(node.type);
|
||||
@@ -132,7 +132,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
while (node) {
|
||||
if (node.tag === HostComponent || node.tag === HostText) {
|
||||
appendInitialChild(parent, node.stateNode);
|
||||
} else if (node.tag === Portal) {
|
||||
} else if (node.tag === HostPortal) {
|
||||
// If we have a portal child, then we don't want to traverse
|
||||
// down its children. Instead, we'll get insertions from each child in
|
||||
// the portal directly.
|
||||
@@ -188,7 +188,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
markCallback(workInProgress);
|
||||
}
|
||||
return null;
|
||||
case HostContainer: {
|
||||
case HostRoot: {
|
||||
workInProgress.memoizedProps = workInProgress.pendingProps;
|
||||
popContextProvider();
|
||||
const fiberRoot = (workInProgress.stateNode : FiberRoot);
|
||||
@@ -290,7 +290,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
case Fragment:
|
||||
workInProgress.memoizedProps = workInProgress.pendingProps;
|
||||
return null;
|
||||
case Portal:
|
||||
case HostPortal:
|
||||
// TODO: Only mark this as an update if we have any pending callbacks.
|
||||
markUpdate(workInProgress);
|
||||
workInProgress.memoizedProps = workInProgress.pendingProps;
|
||||
|
||||
@@ -22,7 +22,7 @@ var {
|
||||
} = require('ReactFiberTreeReflection');
|
||||
var {
|
||||
ClassComponent,
|
||||
HostContainer,
|
||||
HostRoot,
|
||||
} = require('ReactTypeOfWork');
|
||||
|
||||
if (__DEV__) {
|
||||
@@ -142,7 +142,7 @@ exports.findCurrentUnmaskedContext = function(fiber: Fiber) : Object {
|
||||
);
|
||||
|
||||
let node : Fiber = fiber;
|
||||
while (node.tag !== HostContainer) {
|
||||
while (node.tag !== HostRoot) {
|
||||
if (isContextProvider(node)) {
|
||||
return node.stateNode.__reactInternalMemoizedMergedChildContext;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import type { Fiber } from 'ReactFiber';
|
||||
import type { UpdateQueue } from 'ReactFiberUpdateQueue';
|
||||
|
||||
const { createHostContainerFiber } = require('ReactFiber');
|
||||
const { createHostRootFiber } = require('ReactFiber');
|
||||
|
||||
export type FiberRoot = {
|
||||
// Any additional information from the host associated with this root.
|
||||
@@ -36,7 +36,7 @@ export type FiberRoot = {
|
||||
exports.createFiberRoot = function(containerInfo : any, context : Object) : FiberRoot {
|
||||
// Cyclic construction. This cheats the type system right now because
|
||||
// stateNode is any.
|
||||
const uninitializedFiber = createHostContainerFiber();
|
||||
const uninitializedFiber = createHostRootFiber();
|
||||
const root = {
|
||||
current: uninitializedFiber,
|
||||
containerInfo: containerInfo,
|
||||
|
||||
@@ -46,7 +46,7 @@ var {
|
||||
} = require('ReactTypeOfSideEffect');
|
||||
|
||||
var {
|
||||
HostContainer,
|
||||
HostRoot,
|
||||
ClassComponent,
|
||||
} = require('ReactTypeOfWork');
|
||||
|
||||
@@ -622,7 +622,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
// Host containers are a special case. If the failed work itself is a host
|
||||
// container, then it acts as its own boundary. In all other cases, we
|
||||
// ignore the work itself and only search through the parents.
|
||||
if (failedWork.tag === HostContainer) {
|
||||
if (failedWork.tag === HostRoot) {
|
||||
boundary = failedWork;
|
||||
} else {
|
||||
let node = failedWork.return;
|
||||
@@ -633,7 +633,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
// Found an error boundary!
|
||||
boundary = node;
|
||||
}
|
||||
} else if (node.tag === HostContainer) {
|
||||
} else if (node.tag === HostRoot) {
|
||||
// Treat the root like a no-op error boundary.
|
||||
boundary = node;
|
||||
}
|
||||
@@ -686,7 +686,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
captureError(effectfulFiber, e, false);
|
||||
}
|
||||
return;
|
||||
case HostContainer:
|
||||
case HostRoot:
|
||||
if (!firstUncaughtError) {
|
||||
// If this is the host container, we treat it as a no-op error
|
||||
// boundary. We'll throw the first uncaught error once it's safe to
|
||||
@@ -789,7 +789,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
}
|
||||
}
|
||||
if (!node.return) {
|
||||
if (node.tag === HostContainer) {
|
||||
if (node.tag === HostRoot) {
|
||||
const root : FiberRoot = (node.stateNode : any);
|
||||
scheduleWorkAtPriority(root, priorityLevel);
|
||||
} else {
|
||||
|
||||
@@ -19,7 +19,7 @@ var ReactInstanceMap = require('ReactInstanceMap');
|
||||
var invariant = require('invariant');
|
||||
|
||||
var {
|
||||
HostContainer,
|
||||
HostRoot,
|
||||
HostComponent,
|
||||
HostText,
|
||||
} = require('ReactTypeOfWork');
|
||||
@@ -52,8 +52,8 @@ function isFiberMountedImpl(fiber : Fiber) : number {
|
||||
node = node.return;
|
||||
}
|
||||
}
|
||||
if (node.tag === HostContainer) {
|
||||
// TODO: Check if this was a nested HostContainer when used with
|
||||
if (node.tag === HostRoot) {
|
||||
// TODO: Check if this was a nested HostRoot when used with
|
||||
// renderContainerIntoSubtree.
|
||||
return MOUNTED;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ module.exports = {
|
||||
IndeterminateComponent: 0, // Before we know whether it is functional or class
|
||||
FunctionalComponent: 1,
|
||||
ClassComponent: 2,
|
||||
HostContainer: 3, // Root of a host tree. Could be nested inside another node.
|
||||
HostComponent: 4,
|
||||
HostText: 5,
|
||||
CoroutineComponent: 6,
|
||||
CoroutineHandlerPhase: 7,
|
||||
YieldComponent: 8,
|
||||
Fragment: 9,
|
||||
Portal: 10, // A subtree. Could be an entry point to a different renderer.
|
||||
HostRoot: 3, // Root of a host tree. Could be nested inside another node.
|
||||
HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
|
||||
HostComponent: 5,
|
||||
HostText: 6,
|
||||
CoroutineComponent: 7,
|
||||
CoroutineHandlerPhase: 8,
|
||||
YieldComponent: 9,
|
||||
Fragment: 10,
|
||||
};
|
||||
@@ -20,7 +20,7 @@ function getParent(inst) {
|
||||
if (typeof inst.tag === 'number') {
|
||||
do {
|
||||
inst = inst.return;
|
||||
// TODO: If this is a HostContainer we might want to bail out.
|
||||
// TODO: If this is a HostRoot we might want to bail out.
|
||||
// That is depending on if we want nested subtrees (layers) to bubble
|
||||
// events to their parent.
|
||||
} while (inst && inst.tag !== HostComponent);
|
||||
|
||||
Reference in new issue
Block a user