Remove rootContainerInstance from unnecessary places (#25024)

We only really use this for the create APIs since the DOM requires it.

We could probably use the Host Context for this instead since they're
updated at the same time and the namespace is related to this concept.
This commit is contained in:
Sebastian Markbåge
2022-08-01 23:30:04 -04:00
committed by GitHub
parent 3f3b46c845
commit 9fcaf88d58
12 changed files with 14 additions and 100 deletions
+1 -11
View File
@@ -283,7 +283,6 @@ export function trapClickOnNonInteractiveElement(node: HTMLElement) {
function setInitialDOMProperties(
tag: string,
domElement: Element,
rootContainerElement: Element | Document | DocumentFragment,
nextProps: Object,
isCustomComponentTag: boolean,
): void {
@@ -487,7 +486,6 @@ export function setInitialProperties(
domElement: Element,
tag: string,
rawProps: Object,
rootContainerElement: Element | Document | DocumentFragment,
): void {
const isCustomComponentTag = isCustomComponent(tag, rawProps);
if (__DEV__) {
@@ -571,13 +569,7 @@ export function setInitialProperties(
assertValidProps(tag, props);
setInitialDOMProperties(
tag,
domElement,
rootContainerElement,
props,
isCustomComponentTag,
);
setInitialDOMProperties(tag, domElement, props, isCustomComponentTag);
switch (tag) {
case 'input':
@@ -613,7 +605,6 @@ export function diffProperties(
tag: string,
lastRawProps: Object,
nextRawProps: Object,
rootContainerElement: Element | Document | DocumentFragment,
): null | Array<mixed> {
if (__DEV__) {
validatePropertiesInDevelopment(tag, nextRawProps);
@@ -866,7 +857,6 @@ export function diffHydratedProperties(
tag: string,
rawProps: Object,
parentNamespace: string,
rootContainerElement: Element | Document | DocumentFragment,
isConcurrentMode: boolean,
shouldWarnDev: boolean,
): null | Array<mixed> {
+2 -13
View File
@@ -181,7 +181,6 @@ export function getRootHostContext(
export function getChildHostContext(
parentHostContext: HostContext,
type: string,
rootContainerInstance: Container,
): HostContext {
if (__DEV__) {
const parentHostContextDev = ((parentHostContext: any): HostContextDev);
@@ -289,10 +288,9 @@ export function finalizeInitialChildren(
domElement: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): boolean {
setInitialProperties(domElement, type, props, rootContainerInstance);
setInitialProperties(domElement, type, props);
switch (type) {
case 'button':
case 'input':
@@ -311,7 +309,6 @@ export function prepareUpdate(
type: string,
oldProps: Props,
newProps: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): null | Array<mixed> {
if (__DEV__) {
@@ -329,13 +326,7 @@ export function prepareUpdate(
validateDOMNesting(null, string, ownAncestorInfo);
}
}
return diffProperties(
domElement,
type,
oldProps,
newProps,
rootContainerInstance,
);
return diffProperties(domElement, type, oldProps, newProps);
}
export function shouldSetTextContent(type: string, props: Props): boolean {
@@ -828,7 +819,6 @@ export function hydrateInstance(
instance: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
hostContext: HostContext,
internalInstanceHandle: Object,
shouldWarnDev: boolean,
@@ -855,7 +845,6 @@ export function hydrateInstance(
type,
props,
parentNamespace,
rootContainerInstance,
isConcurrentMode,
shouldWarnDev,
);
@@ -404,7 +404,6 @@ export function finalizeInitialChildren(
parentInstance: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): boolean {
return false;
@@ -419,7 +418,6 @@ export function getRootHostContext(
export function getChildHostContext(
parentHostContext: HostContext,
type: string,
rootContainerInstance: Container,
): HostContext {
const prevIsInAParentText = parentHostContext.isInAParentText;
const isInAParentText =
@@ -453,7 +451,6 @@ export function prepareUpdate(
type: string,
oldProps: Props,
newProps: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): null | Object {
const viewConfig = instance.canonical.viewConfig;
@@ -166,7 +166,6 @@ export function finalizeInitialChildren(
parentInstance: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): boolean {
// Don't send a no-op message over the bridge.
@@ -199,7 +198,6 @@ export function getRootHostContext(
export function getChildHostContext(
parentHostContext: HostContext,
type: string,
rootContainerInstance: Container,
): HostContext {
const prevIsInAParentText = parentHostContext.isInAParentText;
const isInAParentText =
@@ -230,7 +228,6 @@ export function prepareUpdate(
type: string,
oldProps: Props,
newProps: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): null | Object {
return UPDATE_SIGNAL;
+1 -5
View File
@@ -276,11 +276,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
return NO_CONTEXT;
},
getChildHostContext(
parentHostContext: HostContext,
type: string,
rootcontainerInstance: Container,
) {
getChildHostContext(parentHostContext: HostContext, type: string) {
if (type === 'offscreen') {
return parentHostContext;
}
@@ -255,7 +255,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
// If we have an alternate, that means this is an update and we need to
// schedule a side-effect to do the updates.
@@ -280,7 +279,6 @@ if (supportsMutation) {
type,
oldProps,
newProps,
rootContainerInstance,
currentHostContext,
);
// TODO: Type this specific to this type of component.
@@ -458,7 +456,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
const currentInstance = current.stateNode;
const oldProps = current.memoizedProps;
@@ -480,7 +477,6 @@ if (supportsMutation) {
type,
oldProps,
newProps,
rootContainerInstance,
currentHostContext,
);
}
@@ -501,13 +497,7 @@ if (supportsMutation) {
recyclableInstance,
);
if (
finalizeInitialChildren(
newInstance,
type,
newProps,
rootContainerInstance,
currentHostContext,
)
finalizeInitialChildren(newInstance, type, newProps, currentHostContext)
) {
markUpdate(workInProgress);
}
@@ -555,7 +545,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
// Noop
};
@@ -964,16 +953,9 @@ function completeWork(
}
case HostComponent: {
popHostContext(workInProgress);
const rootContainerInstance = getRootHostContainer();
const type = workInProgress.type;
if (current !== null && workInProgress.stateNode != null) {
updateHostComponent(
current,
workInProgress,
type,
newProps,
rootContainerInstance,
);
updateHostComponent(current, workInProgress, type, newProps);
if (current.ref !== workInProgress.ref) {
markRef(workInProgress);
@@ -1002,17 +984,14 @@ function completeWork(
// TODO: Move this and createInstance step into the beginPhase
// to consolidate.
if (
prepareToHydrateHostInstance(
workInProgress,
rootContainerInstance,
currentHostContext,
)
prepareToHydrateHostInstance(workInProgress, currentHostContext)
) {
// If changes to the hydrated node need to be applied at the
// commit-phase we mark this as such.
markUpdate(workInProgress);
}
} else {
const rootContainerInstance = getRootHostContainer();
const instance = createInstance(
type,
newProps,
@@ -1033,7 +1012,6 @@ function completeWork(
instance,
type,
newProps,
rootContainerInstance,
currentHostContext,
)
) {
@@ -255,7 +255,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
// If we have an alternate, that means this is an update and we need to
// schedule a side-effect to do the updates.
@@ -280,7 +279,6 @@ if (supportsMutation) {
type,
oldProps,
newProps,
rootContainerInstance,
currentHostContext,
);
// TODO: Type this specific to this type of component.
@@ -458,7 +456,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
const currentInstance = current.stateNode;
const oldProps = current.memoizedProps;
@@ -480,7 +477,6 @@ if (supportsMutation) {
type,
oldProps,
newProps,
rootContainerInstance,
currentHostContext,
);
}
@@ -501,13 +497,7 @@ if (supportsMutation) {
recyclableInstance,
);
if (
finalizeInitialChildren(
newInstance,
type,
newProps,
rootContainerInstance,
currentHostContext,
)
finalizeInitialChildren(newInstance, type, newProps, currentHostContext)
) {
markUpdate(workInProgress);
}
@@ -555,7 +545,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
// Noop
};
@@ -964,16 +953,9 @@ function completeWork(
}
case HostComponent: {
popHostContext(workInProgress);
const rootContainerInstance = getRootHostContainer();
const type = workInProgress.type;
if (current !== null && workInProgress.stateNode != null) {
updateHostComponent(
current,
workInProgress,
type,
newProps,
rootContainerInstance,
);
updateHostComponent(current, workInProgress, type, newProps);
if (current.ref !== workInProgress.ref) {
markRef(workInProgress);
@@ -1002,17 +984,14 @@ function completeWork(
// TODO: Move this and createInstance step into the beginPhase
// to consolidate.
if (
prepareToHydrateHostInstance(
workInProgress,
rootContainerInstance,
currentHostContext,
)
prepareToHydrateHostInstance(workInProgress, currentHostContext)
) {
// If changes to the hydrated node need to be applied at the
// commit-phase we mark this as such.
markUpdate(workInProgress);
}
} else {
const rootContainerInstance = getRootHostContainer();
const instance = createInstance(
type,
newProps,
@@ -1033,7 +1012,6 @@ function completeWork(
instance,
type,
newProps,
rootContainerInstance,
currentHostContext,
)
) {
@@ -75,11 +75,8 @@ function getHostContext(): HostContext {
}
function pushHostContext(fiber: Fiber): void {
const rootInstance: Container = requiredContext(
rootInstanceStackCursor.current,
);
const context: HostContext = requiredContext(contextStackCursor.current);
const nextContext = getChildHostContext(context, fiber.type, rootInstance);
const nextContext = getChildHostContext(context, fiber.type);
// Don't push this Fiber's context unless it's unique.
if (context === nextContext) {
@@ -75,11 +75,8 @@ function getHostContext(): HostContext {
}
function pushHostContext(fiber: Fiber): void {
const rootInstance: Container = requiredContext(
rootInstanceStackCursor.current,
);
const context: HostContext = requiredContext(contextStackCursor.current);
const nextContext = getChildHostContext(context, fiber.type, rootInstance);
const nextContext = getChildHostContext(context, fiber.type);
// Don't push this Fiber's context unless it's unique.
if (context === nextContext) {
@@ -444,7 +444,6 @@ function tryToClaimNextHydratableInstance(fiber: Fiber): void {
function prepareToHydrateHostInstance(
fiber: Fiber,
rootContainerInstance: Container,
hostContext: HostContext,
): boolean {
if (!supportsHydration) {
@@ -460,7 +459,6 @@ function prepareToHydrateHostInstance(
instance,
fiber.type,
fiber.memoizedProps,
rootContainerInstance,
hostContext,
fiber,
shouldWarnIfMismatchDev,
@@ -444,7 +444,6 @@ function tryToClaimNextHydratableInstance(fiber: Fiber): void {
function prepareToHydrateHostInstance(
fiber: Fiber,
rootContainerInstance: Container,
hostContext: HostContext,
): boolean {
if (!supportsHydration) {
@@ -460,7 +459,6 @@ function prepareToHydrateHostInstance(
instance,
fiber.type,
fiber.memoizedProps,
rootContainerInstance,
hostContext,
fiber,
shouldWarnIfMismatchDev,
@@ -128,7 +128,6 @@ export function getRootHostContext(
export function getChildHostContext(
parentHostContext: HostContext,
type: string,
rootContainerInstance: Container,
): HostContext {
return NO_CONTEXT;
}