@@ -793,10 +793,20 @@ export function appendChildToContainer(
793
793
let parentNode ;
794
794
if ( container . nodeType === COMMENT_NODE ) {
795
795
parentNode = ( container . parentNode : any ) ;
796
- parentNode . insertBefore ( child , container ) ;
796
+ if ( supportsMoveBefore ) {
797
+ // $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
798
+ parentNode . moveBefore ( child , container ) ;
799
+ } else {
800
+ parentNode . insertBefore ( child , container ) ;
801
+ }
797
802
} else {
798
803
parentNode = container ;
799
- parentNode . appendChild ( child ) ;
804
+ if ( supportsMoveBefore ) {
805
+ // $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
806
+ parentNode . moveBefore ( child , null) ;
807
+ } else {
808
+ parentNode . appendChild ( child ) ;
809
+ }
800
810
}
801
811
// This container might be used for a portal.
802
812
// If something inside a portal is clicked, that click should bubble
@@ -835,9 +845,19 @@ export function insertInContainerBefore(
835
845
beforeChild : Instance | TextInstance | SuspenseInstance ,
836
846
) : void {
837
847
if ( container . nodeType === COMMENT_NODE ) {
838
- ( container . parentNode : any ) . insertBefore ( child , beforeChild ) ;
848
+ if ( supportsMoveBefore ) {
849
+ // $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
850
+ ( container . parentNode : any ) . moveBefore ( child , beforeChild ) ;
851
+ } else {
852
+ ( container . parentNode : any ) . insertBefore ( child , beforeChild ) ;
853
+ }
839
854
} else {
840
- container . insertBefore ( child , beforeChild ) ;
855
+ if ( supportsMoveBefore ) {
856
+ // $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
857
+ container . moveBefore ( child , beforeChild) ;
858
+ } else {
859
+ container . insertBefore ( child , beforeChild ) ;
860
+ }
841
861
}
842
862
}
843
863
0 commit comments