Skip to content

Commit ec38036

Browse files
committed
gate clearContainer
1 parent 272dce4 commit ec38036

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

packages/react-dom/src/client/ReactDOMHostConfig.js

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -696,24 +696,34 @@ export function unhideTextInstance(
696696
}
697697

698698
export function clearContainer(container: Container): void {
699-
if (container.nodeType === ELEMENT_NODE) {
700-
switch (((container: any): Element).tagName.toLowerCase()) {
701-
case 'html': {
702-
break;
703-
}
704-
case 'head':
705-
case 'body': {
706-
resetSingletonInstance(container);
707-
break;
699+
if (enableFloat) {
700+
if (container.nodeType === ELEMENT_NODE) {
701+
switch (((container: any): Element).tagName.toLowerCase()) {
702+
case 'html': {
703+
break;
704+
}
705+
case 'head':
706+
case 'body': {
707+
resetSingletonInstance(container);
708+
break;
709+
}
710+
default: {
711+
((container: any): Element).textContent = '';
712+
}
708713
}
709-
default: {
710-
((container: any): Element).textContent = '';
714+
}
715+
// Implicitly if the container is of type Document we rely on the Persistent HostComponent
716+
// semantics to clear these nodes appropriately when being placed so no ahead of time
717+
// clearing is necessary
718+
} else {
719+
if (container.nodeType === ELEMENT_NODE) {
720+
((container: any): Element).textContent = '';
721+
} else if (container.nodeType === DOCUMENT_NODE) {
722+
if (container.documentElement) {
723+
container.removeChild(container.documentElement);
711724
}
712725
}
713726
}
714-
// Implicitly if the container is of type Document we rely on the Persistent HostComponent
715-
// semantics to clear these nodes appropriately when being placed so no ahead of time
716-
// clearing is necessary
717727
}
718728

719729
// -------------------

0 commit comments

Comments
 (0)