File tree Expand file tree Collapse file tree
packages/react-dom/src/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -696,24 +696,34 @@ export function unhideTextInstance(
696696}
697697
698698export 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// -------------------
You can’t perform that action at this time.
0 commit comments