Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove rootContainerInstance from unnecessary places #25024

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions packages/react-dom/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ export function trapClickOnNonInteractiveElement(node: HTMLElement) {
function setInitialDOMProperties(
tag: string,
domElement: Element,
rootContainerElement: Element | Document | DocumentFragment,
nextProps: Object,
isCustomComponentTag: boolean,
): void {
Expand Down Expand Up @@ -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__) {
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -866,7 +857,6 @@ export function diffHydratedProperties(
tag: string,
rawProps: Object,
parentNamespace: string,
rootContainerElement: Element | Document | DocumentFragment,
isConcurrentMode: boolean,
shouldWarnDev: boolean,
): null | Array<mixed> {
Expand Down
15 changes: 2 additions & 13 deletions packages/react-dom/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ export function getRootHostContext(
export function getChildHostContext(
parentHostContext: HostContext,
type: string,
rootContainerInstance: Container,
): HostContext {
if (__DEV__) {
const parentHostContextDev = ((parentHostContext: any): HostContextDev);
Expand Down Expand Up @@ -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':
Expand All @@ -311,7 +309,6 @@ export function prepareUpdate(
type: string,
oldProps: Props,
newProps: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): null | Array<mixed> {
if (__DEV__) {
Expand All @@ -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 {
Expand Down Expand Up @@ -828,7 +819,6 @@ export function hydrateInstance(
instance: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
hostContext: HostContext,
internalInstanceHandle: Object,
shouldWarnDev: boolean,
Expand All @@ -855,7 +845,6 @@ export function hydrateInstance(
type,
props,
parentNamespace,
rootContainerInstance,
isConcurrentMode,
shouldWarnDev,
);
Expand Down
3 changes: 0 additions & 3 deletions packages/react-native-renderer/src/ReactFabricHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ export function finalizeInitialChildren(
parentInstance: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): boolean {
return false;
Expand All @@ -419,7 +418,6 @@ export function getRootHostContext(
export function getChildHostContext(
parentHostContext: HostContext,
type: string,
rootContainerInstance: Container,
): HostContext {
const prevIsInAParentText = parentHostContext.isInAParentText;
const isInAParentText =
Expand Down Expand Up @@ -453,7 +451,6 @@ export function prepareUpdate(
type: string,
oldProps: Props,
newProps: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): null | Object {
const viewConfig = instance.canonical.viewConfig;
Expand Down
3 changes: 0 additions & 3 deletions packages/react-native-renderer/src/ReactNativeHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -199,7 +198,6 @@ export function getRootHostContext(
export function getChildHostContext(
parentHostContext: HostContext,
type: string,
rootContainerInstance: Container,
): HostContext {
const prevIsInAParentText = parentHostContext.isInAParentText;
const isInAParentText =
Expand Down Expand Up @@ -230,7 +228,6 @@ export function prepareUpdate(
type: string,
oldProps: Props,
newProps: Props,
rootContainerInstance: Container,
hostContext: HostContext,
): null | Object {
return UPDATE_SIGNAL;
Expand Down
6 changes: 1 addition & 5 deletions packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
30 changes: 4 additions & 26 deletions packages/react-reconciler/src/ReactFiberCompleteWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -280,7 +279,6 @@ if (supportsMutation) {
type,
oldProps,
newProps,
rootContainerInstance,
currentHostContext,
);
// TODO: Type this specific to this type of component.
Expand Down Expand Up @@ -458,7 +456,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
const currentInstance = current.stateNode;
const oldProps = current.memoizedProps;
Expand All @@ -480,7 +477,6 @@ if (supportsMutation) {
type,
oldProps,
newProps,
rootContainerInstance,
currentHostContext,
);
}
Expand All @@ -501,13 +497,7 @@ if (supportsMutation) {
recyclableInstance,
);
if (
finalizeInitialChildren(
newInstance,
type,
newProps,
rootContainerInstance,
currentHostContext,
)
finalizeInitialChildren(newInstance, type, newProps, currentHostContext)
) {
markUpdate(workInProgress);
}
Expand Down Expand Up @@ -555,7 +545,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
// Noop
};
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -1033,7 +1012,6 @@ function completeWork(
instance,
type,
newProps,
rootContainerInstance,
currentHostContext,
)
) {
Expand Down
30 changes: 4 additions & 26 deletions packages/react-reconciler/src/ReactFiberCompleteWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -280,7 +279,6 @@ if (supportsMutation) {
type,
oldProps,
newProps,
rootContainerInstance,
currentHostContext,
);
// TODO: Type this specific to this type of component.
Expand Down Expand Up @@ -458,7 +456,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
const currentInstance = current.stateNode;
const oldProps = current.memoizedProps;
Expand All @@ -480,7 +477,6 @@ if (supportsMutation) {
type,
oldProps,
newProps,
rootContainerInstance,
currentHostContext,
);
}
Expand All @@ -501,13 +497,7 @@ if (supportsMutation) {
recyclableInstance,
);
if (
finalizeInitialChildren(
newInstance,
type,
newProps,
rootContainerInstance,
currentHostContext,
)
finalizeInitialChildren(newInstance, type, newProps, currentHostContext)
) {
markUpdate(workInProgress);
}
Expand Down Expand Up @@ -555,7 +545,6 @@ if (supportsMutation) {
workInProgress: Fiber,
type: Type,
newProps: Props,
rootContainerInstance: Container,
) {
// Noop
};
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -1033,7 +1012,6 @@ function completeWork(
instance,
type,
newProps,
rootContainerInstance,
currentHostContext,
)
) {
Expand Down
5 changes: 1 addition & 4 deletions packages/react-reconciler/src/ReactFiberHostContext.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions packages/react-reconciler/src/ReactFiberHostContext.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading