Skip to content

Commit a26d25c

Browse files
committed
Check for moveBefore on instance instead of prototype
1 parent 5d04d73 commit a26d25c

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -932,18 +932,12 @@ export function commitTextUpdate(
932932
textInstance.nodeValue = newText;
933933
}
934934

935-
const supportsMoveBefore =
936-
// $FlowFixMe[prop-missing]: We're doing the feature detection here.
937-
enableMoveBefore &&
938-
typeof window !== 'undefined' &&
939-
typeof window.Element.prototype.moveBefore === 'function';
940-
941935
export function appendChild(
942936
parentInstance: Instance,
943937
child: Instance | TextInstance,
944938
): void {
945-
if (supportsMoveBefore && child.parentNode !== null) {
946-
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
939+
if (enableMoveBefore && typeof (parentInstance: any).moveBefore === 'function' && child.parentNode !== null) {
940+
// $FlowFixMe[prop-missing]: We've checked this above.
947941
parentInstance.moveBefore(child, null);
948942
} else {
949943
parentInstance.appendChild(child);
@@ -1003,8 +997,8 @@ export function appendChildToContainer(
1003997
container.nodeType === COMMENT_NODE
1004998
) {
1005999
parentNode = (container.parentNode: any);
1006-
if (supportsMoveBefore && child.parentNode !== null) {
1007-
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
1000+
if (enableMoveBefore && typeof parentNode.moveBefore === 'function' && child.parentNode !== null) {
1001+
// $FlowFixMe[prop-missing]: We've checked this above.
10081002
parentNode.moveBefore(child, container);
10091003
} else {
10101004
parentNode.insertBefore(child, container);
@@ -1015,8 +1009,8 @@ export function appendChildToContainer(
10151009
} else {
10161010
parentNode = (container: any);
10171011
}
1018-
if (supportsMoveBefore && child.parentNode !== null) {
1019-
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
1012+
if (enableMoveBefore && typeof parentNode.moveBefore === 'function' && child.parentNode !== null) {
1013+
// $FlowFixMe[prop-missing]: We've checked this above.
10201014
parentNode.moveBefore(child, null);
10211015
} else {
10221016
parentNode.appendChild(child);
@@ -1045,8 +1039,8 @@ export function insertBefore(
10451039
child: Instance | TextInstance,
10461040
beforeChild: Instance | TextInstance | SuspenseInstance | ActivityInstance,
10471041
): void {
1048-
if (supportsMoveBefore && child.parentNode !== null) {
1049-
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
1042+
if (enableMoveBefore && typeof (parentInstance: any).moveBefore === 'function' && child.parentNode !== null) {
1043+
// $FlowFixMe[prop-missing]: We've checked this above.
10501044
parentInstance.moveBefore(child, beforeChild);
10511045
} else {
10521046
parentInstance.insertBefore(child, beforeChild);
@@ -1074,8 +1068,8 @@ export function insertInContainerBefore(
10741068
} else {
10751069
parentNode = (container: any);
10761070
}
1077-
if (supportsMoveBefore && child.parentNode !== null) {
1078-
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
1071+
if (enableMoveBefore && typeof parentNode.moveBefore === 'function' && child.parentNode !== null) {
1072+
// $FlowFixMe[prop-missing]: We've checked this above.
10791073
parentNode.moveBefore(child, beforeChild);
10801074
} else {
10811075
parentNode.insertBefore(child, beforeChild);

0 commit comments

Comments
 (0)