Rename HostContainer => HostRoot, Portal => HostPortal (#8474)
Dan Abramov committed
Dec 1, 2016 at 18:36 UTC
df9dc8933387c5f1e6126ce38e95771c890f8e4f
12 files changed
+58
-58
src/renderers/dom/shared/ReactEventListener.js
+2
-2
@@ -21,7 +21,7 @@ var ReactTypeOfWork = require('ReactTypeOfWork');
21
var getEventTarget = require('getEventTarget');
22
var getUnboundedScrollPosition = require('getUnboundedScrollPosition');
23
24
-var { HostContainer } = ReactTypeOfWork;
24
+var { HostRoot } = ReactTypeOfWork;
25
26
/**
27
* Find the deepest React component completely containing the root of the
@@ -36,7 +36,7 @@ function findRootContainerNode(inst) {
36
while (inst.return) {
37
inst = inst.return;
38
}
39
- if (inst.tag !== HostContainer) {
39
+ if (inst.tag !== HostRoot) {
40
// This can happen if we're in a detached tree.
41
return null;
42
}
src/renderers/shared/fiber/ReactChildFiber.js
+3
-3
@@ -56,10 +56,10 @@ const isArray = Array.isArray;
56
const {
57
ClassComponent,
58
HostText,
59
+ HostPortal,
60
CoroutineComponent,
61
YieldComponent,
62
Fragment,
62
- Portal,
63
} = ReactTypeOfWork;
64
65
const {
@@ -330,7 +330,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
330
) : Fiber {
331
if (
332
current == null ||
333
- current.tag !== Portal ||
333
+ current.tag !== HostPortal ||
334
current.stateNode.containerInfo !== portal.containerInfo ||
335
current.stateNode.implementation !== portal.implementation
336
) {
@@ -970,7 +970,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
970
// the first item in the list.
971
if (child.key === key) {
972
if (
973
- child.tag === Portal &&
973
+ child.tag === HostPortal &&
974
child.stateNode.containerInfo === portal.containerInfo &&
975
child.stateNode.implementation === portal.implementation
976
) {
src/renderers/shared/fiber/ReactFiber.js
+5
-5
@@ -24,13 +24,13 @@ var ReactTypeOfWork = require('ReactTypeOfWork');
24
var {
25
IndeterminateComponent,
26
ClassComponent,
27
- HostContainer,
27
+ HostRoot,
28
HostComponent,
29
HostText,
30
+ HostPortal,
31
CoroutineComponent,
32
YieldComponent,
33
Fragment,
33
- Portal,
34
} = ReactTypeOfWork;
35
36
var {
@@ -269,8 +269,8 @@ exports.cloneFiber = function(fiber : Fiber, priorityLevel : PriorityLevel) : Fi
269
return alt;
270
};
271
272
-exports.createHostContainerFiber = function() : Fiber {
273
- const fiber = createFiber(HostContainer, null);
272
+exports.createHostRootFiber = function() : Fiber {
273
+ const fiber = createFiber(HostRoot, null);
274
return fiber;
275
};
276
@@ -345,7 +345,7 @@ exports.createFiberFromYield = function(yieldNode : ReactYield, priorityLevel :
345
};
346
347
exports.createFiberFromPortal = function(portal : ReactPortal, priorityLevel : PriorityLevel) : Fiber {
348
- const fiber = createFiber(Portal, portal.key);
348
+ const fiber = createFiber(HostPortal, portal.key);
349
fiber.pendingProps = portal.children;
350
fiber.pendingWorkPriority = priorityLevel;
351
fiber.stateNode = {
src/renderers/shared/fiber/ReactFiberBeginWork.js
+5
-5
@@ -38,14 +38,14 @@ var {
38
IndeterminateComponent,
39
FunctionalComponent,
40
ClassComponent,
41
- HostContainer,
41
+ HostRoot,
42
HostComponent,
43
HostText,
44
+ HostPortal,
45
CoroutineComponent,
46
CoroutineHandlerPhase,
47
YieldComponent,
48
Fragment,
48
- Portal,
49
} = ReactTypeOfWork;
50
var {
51
NoWork,
@@ -449,7 +449,7 @@ module.exports = function<T, P, I, TI, C>(
449
return updateFunctionalComponent(current, workInProgress);
450
case ClassComponent:
451
return updateClassComponent(current, workInProgress);
452
- case HostContainer: {
452
+ case HostRoot: {
453
const root = (workInProgress.stateNode : FiberRoot);
454
if (root.pendingContext) {
455
pushTopLevelContextObject(
@@ -483,7 +483,7 @@ module.exports = function<T, P, I, TI, C>(
483
// A yield component is just a placeholder, we can just run through the
484
// next one immediately.
485
return null;
486
- case Portal:
486
+ case HostPortal:
487
updatePortalComponent(current, workInProgress);
488
// TODO: is this right?
489
return workInProgress.child;
@@ -497,7 +497,7 @@ module.exports = function<T, P, I, TI, C>(
497
498
function beginFailedWork(current : ?Fiber, workInProgress : Fiber, priorityLevel : PriorityLevel) {
499
if (workInProgress.tag !== ClassComponent &&
500
- workInProgress.tag !== HostContainer) {
500
+ workInProgress.tag !== HostRoot) {
501
throw new Error('Invalid type of work');
502
}
503
src/renderers/shared/fiber/ReactFiberCommitWork.js
+16
-16
@@ -18,11 +18,11 @@ import type { HostConfig } from 'ReactFiberReconciler';
18
var ReactTypeOfWork = require('ReactTypeOfWork');
19
var {
20
ClassComponent,
21
- HostContainer,
21
+ HostRoot,
22
HostComponent,
23
HostText,
24
+ HostPortal,
25
CoroutineComponent,
25
- Portal,
26
} = ReactTypeOfWork;
27
var { callCallbacks } = require('ReactFiberUpdateQueue');
28
@@ -75,9 +75,9 @@ module.exports = function<T, P, I, TI, C>(
75
switch (parent.tag) {
76
case HostComponent:
77
return parent.stateNode;
78
- case HostContainer:
78
+ case HostRoot:
79
return parent.stateNode.containerInfo;
80
- case Portal:
80
+ case HostPortal:
81
return parent.stateNode.containerInfo;
82
}
83
parent = parent.return;
@@ -99,8 +99,8 @@ module.exports = function<T, P, I, TI, C>(
99
function isHostParent(fiber : Fiber) : boolean {
100
return (
101
fiber.tag === HostComponent ||
102
- fiber.tag === HostContainer ||
103
- fiber.tag === Portal
102
+ fiber.tag === HostRoot ||
103
+ fiber.tag === HostPortal
104
);
105
}
106
@@ -153,10 +153,10 @@ module.exports = function<T, P, I, TI, C>(
153
case HostComponent:
154
parent = parentFiber.stateNode;
155
break;
156
- case HostContainer:
156
+ case HostRoot:
157
parent = parentFiber.stateNode.containerInfo;
158
break;
159
- case Portal:
159
+ case HostPortal:
160
parent = parentFiber.stateNode.containerInfo;
161
break;
162
default:
@@ -180,7 +180,7 @@ module.exports = function<T, P, I, TI, C>(
180
} else {
181
appendChild(parent, node.stateNode);
182
}
183
- } else if (node.tag === Portal) {
183
+ } else if (node.tag === HostPortal) {
184
// If the insertion itself is a portal, then we don't want to traverse
185
// down its children. Instead, we'll get insertions from each child in
186
// the portal directly.
@@ -243,7 +243,7 @@ module.exports = function<T, P, I, TI, C>(
243
// After all the children have unmounted, it is now safe to remove the
244
// node from the tree.
245
removeChild(parent, node.stateNode);
246
- } else if (node.tag === Portal) {
246
+ } else if (node.tag === HostPortal) {
247
// When we go into a portal, it becomes the parent to remove from.
248
// We will reassign it back when we pop the portal on the way up.
249
parent = node.stateNode.containerInfo;
@@ -268,7 +268,7 @@ module.exports = function<T, P, I, TI, C>(
268
return;
269
}
270
node = node.return;
271
- if (node.tag === Portal) {
271
+ if (node.tag === HostPortal) {
272
// When we go out of the portal, we need to restore the parent.
273
// Since we don't keep a stack of them, we will search for it.
274
parent = getHostParent(node);
@@ -319,7 +319,7 @@ module.exports = function<T, P, I, TI, C>(
319
commitNestedUnmounts(current.stateNode);
320
return;
321
}
322
- case Portal: {
322
+ case HostPortal: {
323
// TODO: this is recursive.
324
commitDeletion(current);
325
return;
@@ -354,10 +354,10 @@ module.exports = function<T, P, I, TI, C>(
354
commitTextUpdate(textInstance, oldText, newText);
355
return;
356
}
357
- case HostContainer: {
357
+ case HostRoot: {
358
return;
359
}
360
- case Portal: {
360
+ case HostPortal: {
361
return;
362
}
363
default:
@@ -400,7 +400,7 @@ module.exports = function<T, P, I, TI, C>(
400
}
401
return;
402
}
403
- case HostContainer: {
403
+ case HostRoot: {
404
const rootFiber = finishedWork.stateNode;
405
let firstError = null;
406
if (rootFiber.callbackList) {
@@ -422,7 +422,7 @@ module.exports = function<T, P, I, TI, C>(
422
// We have no life-cycles associated with text.
423
return;
424
}
425
- case Portal: {
425
+ case HostPortal: {
426
// We have no life-cycles associated with portals.
427
return;
428
}
src/renderers/shared/fiber/ReactFiberCompleteWork.js
+6
-6
@@ -29,14 +29,14 @@ var {
29
IndeterminateComponent,
30
FunctionalComponent,
31
ClassComponent,
32
- HostContainer,
32
+ HostRoot,
33
HostComponent,
34
HostText,
35
+ HostPortal,
36
CoroutineComponent,
37
CoroutineHandlerPhase,
38
YieldComponent,
39
Fragment,
39
- Portal,
40
} = ReactTypeOfWork;
41
var {
42
Update,
@@ -66,7 +66,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
66
let node = workInProgress.child;
67
while (node) {
68
if (node.tag === HostComponent || node.tag === HostText ||
69
- node.tag === Portal) {
69
+ node.tag === HostPortal) {
70
throw new Error('A coroutine cannot have host component children.');
71
} else if (node.tag === YieldComponent) {
72
yields.push(node.type);
@@ -132,7 +132,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
132
while (node) {
133
if (node.tag === HostComponent || node.tag === HostText) {
134
appendInitialChild(parent, node.stateNode);
135
- } else if (node.tag === Portal) {
135
+ } else if (node.tag === HostPortal) {
136
// If we have a portal child, then we don't want to traverse
137
// down its children. Instead, we'll get insertions from each child in
138
// the portal directly.
@@ -188,7 +188,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
188
markCallback(workInProgress);
189
}
190
return null;
191
- case HostContainer: {
191
+ case HostRoot: {
192
workInProgress.memoizedProps = workInProgress.pendingProps;
193
popContextProvider();
194
const fiberRoot = (workInProgress.stateNode : FiberRoot);
@@ -290,7 +290,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
290
case Fragment:
291
workInProgress.memoizedProps = workInProgress.pendingProps;
292
return null;
293
- case Portal:
293
+ case HostPortal:
294
// TODO: Only mark this as an update if we have any pending callbacks.
295
markUpdate(workInProgress);
296
workInProgress.memoizedProps = workInProgress.pendingProps;
src/renderers/shared/fiber/ReactFiberContext.js
+2
-2
@@ -22,7 +22,7 @@ var {
22
} = require('ReactFiberTreeReflection');
23
var {
24
ClassComponent,
25
- HostContainer,
25
+ HostRoot,
26
} = require('ReactTypeOfWork');
27
28
if (__DEV__) {
@@ -142,7 +142,7 @@ exports.findCurrentUnmaskedContext = function(fiber: Fiber) : Object {
142
);
143
144
let node : Fiber = fiber;
145
- while (node.tag !== HostContainer) {
145
+ while (node.tag !== HostRoot) {
146
if (isContextProvider(node)) {
147
return node.stateNode.__reactInternalMemoizedMergedChildContext;
148
}
src/renderers/shared/fiber/ReactFiberRoot.js
+2
-2
@@ -15,7 +15,7 @@
15
import type { Fiber } from 'ReactFiber';
16
import type { UpdateQueue } from 'ReactFiberUpdateQueue';
17
18
-const { createHostContainerFiber } = require('ReactFiber');
18
+const { createHostRootFiber } = require('ReactFiber');
19
20
export type FiberRoot = {
21
// Any additional information from the host associated with this root.
@@ -36,7 +36,7 @@ export type FiberRoot = {
36
exports.createFiberRoot = function(containerInfo : any, context : Object) : FiberRoot {
37
// Cyclic construction. This cheats the type system right now because
38
// stateNode is any.
39
- const uninitializedFiber = createHostContainerFiber();
39
+ const uninitializedFiber = createHostRootFiber();
40
const root = {
41
current: uninitializedFiber,
42
containerInfo: containerInfo,
src/renderers/shared/fiber/ReactFiberScheduler.js
+5
-5
@@ -46,7 +46,7 @@ var {
46
} = require('ReactTypeOfSideEffect');
47
48
var {
49
- HostContainer,
49
+ HostRoot,
50
ClassComponent,
51
} = require('ReactTypeOfWork');
52
@@ -622,7 +622,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
622
// Host containers are a special case. If the failed work itself is a host
623
// container, then it acts as its own boundary. In all other cases, we
624
// ignore the work itself and only search through the parents.
625
- if (failedWork.tag === HostContainer) {
625
+ if (failedWork.tag === HostRoot) {
626
boundary = failedWork;
627
} else {
628
let node = failedWork.return;
@@ -633,7 +633,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
633
// Found an error boundary!
634
boundary = node;
635
}
636
- } else if (node.tag === HostContainer) {
636
+ } else if (node.tag === HostRoot) {
637
// Treat the root like a no-op error boundary.
638
boundary = node;
639
}
@@ -686,7 +686,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
686
captureError(effectfulFiber, e, false);
687
}
688
return;
689
- case HostContainer:
689
+ case HostRoot:
690
if (!firstUncaughtError) {
691
// If this is the host container, we treat it as a no-op error
692
// 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>) {
789
}
790
}
791
if (!node.return) {
792
- if (node.tag === HostContainer) {
792
+ if (node.tag === HostRoot) {
793
const root : FiberRoot = (node.stateNode : any);
794
scheduleWorkAtPriority(root, priorityLevel);
795
} else {
src/renderers/shared/fiber/ReactFiberTreeReflection.js
+3
-3
@@ -19,7 +19,7 @@ var ReactInstanceMap = require('ReactInstanceMap');
19
var invariant = require('invariant');
20
21
var {
22
- HostContainer,
22
+ HostRoot,
23
HostComponent,
24
HostText,
25
} = require('ReactTypeOfWork');
@@ -52,8 +52,8 @@ function isFiberMountedImpl(fiber : Fiber) : number {
52
node = node.return;
53
}
54
}
55
- if (node.tag === HostContainer) {
56
- // TODO: Check if this was a nested HostContainer when used with
55
+ if (node.tag === HostRoot) {
56
+ // TODO: Check if this was a nested HostRoot when used with
57
// renderContainerIntoSubtree.
58
return MOUNTED;
59
}
src/renderers/shared/fiber/ReactTypeOfWork.js
+8
-8
@@ -18,12 +18,12 @@ module.exports = {
18
IndeterminateComponent: 0, // Before we know whether it is functional or class
19
FunctionalComponent: 1,
20
ClassComponent: 2,
21
- HostContainer: 3, // Root of a host tree. Could be nested inside another node.
22
- HostComponent: 4,
23
- HostText: 5,
24
- CoroutineComponent: 6,
25
- CoroutineHandlerPhase: 7,
26
- YieldComponent: 8,
27
- Fragment: 9,
28
- Portal: 10, // A subtree. Could be an entry point to a different renderer.
21
+ HostRoot: 3, // Root of a host tree. Could be nested inside another node.
22
+ HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
23
+ HostComponent: 5,
24
+ HostText: 6,
25
+ CoroutineComponent: 7,
26
+ CoroutineHandlerPhase: 8,
27
+ YieldComponent: 9,
28
+ Fragment: 10,
29
};
src/renderers/shared/shared/ReactTreeTraversal.js
+1
-1
@@ -20,7 +20,7 @@ function getParent(inst) {
20
if (typeof inst.tag === 'number') {
21
do {
22
inst = inst.return;
23
- // TODO: If this is a HostContainer we might want to bail out.
23
+ // TODO: If this is a HostRoot we might want to bail out.
24
// That is depending on if we want nested subtrees (layers) to bubble
25
// events to their parent.
26
} while (inst && inst.tag !== HostComponent);