Skip to content
Closed
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
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export function unhideTextInstance(textInstance, text): void {
// Noop
}

export function clearContainer(container) {
export function clearContainer(container, scope) {
// TODO Implement this
}

Expand Down
22 changes: 15 additions & 7 deletions packages/react-dom/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,13 +634,21 @@ export function unhideTextInstance(
textInstance.nodeValue = text;
}

export function clearContainer(container: Container): void {
if (container.nodeType === ELEMENT_NODE) {
((container: any): Element).textContent = '';
} else if (container.nodeType === DOCUMENT_NODE) {
const body = ((container: any): Document).body;
if (body != null) {
body.textContent = '';
export function clearContainer(container: Container, root: RootType): void {
const legacyRootContainer = container._reactRootContainer;
// If there is a legacy root container, check to see if the root
// matches the root's container that we want to clear.
if (
legacyRootContainer == null ||
legacyRootContainer._internalRoot === root
) {
if (container.nodeType === ELEMENT_NODE) {
((container: any): Element).textContent = '';
} else if (container.nodeType === DOCUMENT_NODE) {
const body = ((container: any): Document).body;
if (body != null) {
body.textContent = '';
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ export function unhideInstance(instance: Instance, props: Props): void {
);
}

export function clearContainer(container: Container): void {
export function clearContainer(container: Container, scope: Object): void {
// TODO Implement this for React Native
// UIManager does not expose a "remove all" type method.
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function commitBeforeMutationLifeCycles(
if (supportsMutation) {
if (finishedWork.effectTag & Snapshot) {
const root = finishedWork.stateNode;
clearContainer(root.containerInfo);
clearContainer(root.containerInfo, root);
}
}
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ function commitBeforeMutationLifeCycles(
if (supportsMutation) {
if (finishedWork.effectTag & Snapshot) {
const root = finishedWork.stateNode;
clearContainer(root.containerInfo);
clearContainer(root.containerInfo, root);
}
}
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-test-renderer/src/ReactTestHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function removeChild(
parentInstance.children.splice(index, 1);
}

export function clearContainer(container: Container): void {
export function clearContainer(container: Container, root: Object): void {
container.children.splice(0);
}

Expand Down