Skip to content
Closed
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
46 changes: 30 additions & 16 deletions packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -932,18 +932,16 @@ export function commitTextUpdate(
textInstance.nodeValue = newText;
}

const supportsMoveBefore =
// $FlowFixMe[prop-missing]: We're doing the feature detection here.
enableMoveBefore &&
typeof window !== 'undefined' &&
typeof window.Element.prototype.moveBefore === 'function';

export function appendChild(
parentInstance: Instance,
child: Instance | TextInstance,
): void {
if (supportsMoveBefore && child.parentNode !== null) {
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
if (
enableMoveBefore &&
typeof (parentInstance: any).moveBefore === 'function' &&
child.parentNode !== null
) {
// $FlowFixMe[prop-missing]: We've checked this above.
parentInstance.moveBefore(child, null);
} else {
parentInstance.appendChild(child);
Expand Down Expand Up @@ -1003,8 +1001,12 @@ export function appendChildToContainer(
container.nodeType === COMMENT_NODE
) {
parentNode = (container.parentNode: any);
if (supportsMoveBefore && child.parentNode !== null) {
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
if (
enableMoveBefore &&
typeof parentNode.moveBefore === 'function' &&
child.parentNode !== null
) {
// $FlowFixMe[prop-missing]: We've checked this above.
parentNode.moveBefore(child, container);
} else {
parentNode.insertBefore(child, container);
Expand All @@ -1015,8 +1017,12 @@ export function appendChildToContainer(
} else {
parentNode = (container: any);
}
if (supportsMoveBefore && child.parentNode !== null) {
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
if (
enableMoveBefore &&
typeof parentNode.moveBefore === 'function' &&
child.parentNode !== null
) {
// $FlowFixMe[prop-missing]: We've checked this above.
parentNode.moveBefore(child, null);
} else {
parentNode.appendChild(child);
Expand Down Expand Up @@ -1045,8 +1051,12 @@ export function insertBefore(
child: Instance | TextInstance,
beforeChild: Instance | TextInstance | SuspenseInstance | ActivityInstance,
): void {
if (supportsMoveBefore && child.parentNode !== null) {
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
if (
enableMoveBefore &&
typeof (parentInstance: any).moveBefore === 'function' &&
child.parentNode !== null
) {
// $FlowFixMe[prop-missing]: We've checked this above.
parentInstance.moveBefore(child, beforeChild);
} else {
parentInstance.insertBefore(child, beforeChild);
Expand Down Expand Up @@ -1074,8 +1084,12 @@ export function insertInContainerBefore(
} else {
parentNode = (container: any);
}
if (supportsMoveBefore && child.parentNode !== null) {
// $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
if (
enableMoveBefore &&
typeof parentNode.moveBefore === 'function' &&
child.parentNode !== null
) {
// $FlowFixMe[prop-missing]: We've checked this above.
parentNode.moveBefore(child, beforeChild);
} else {
parentNode.insertBefore(child, beforeChild);
Expand Down
Loading