From ffd0d3163de9a84240dbd4b785522e77bad4fcc8 Mon Sep 17 00:00:00 2001 From: jdecroock Date: Fri, 14 Feb 2025 12:46:12 +0100 Subject: [PATCH] Remove contains with a simple parentNode check --- compat/src/portals.js | 1 - src/diff/children.js | 2 +- src/index.d.ts | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/compat/src/portals.js b/compat/src/portals.js index c480a3d3a3..4cdeff370e 100644 --- a/compat/src/portals.js +++ b/compat/src/portals.js @@ -39,7 +39,6 @@ function Portal(props) { nodeType: 1, parentNode: container, childNodes: [], - contains: () => true, // Technically this isn't needed appendChild(child) { this.childNodes.push(child); diff --git a/src/diff/children.js b/src/diff/children.js index 5053a51174..7938e302e3 100644 --- a/src/diff/children.js +++ b/src/diff/children.js @@ -339,7 +339,7 @@ function insert(parentVNode, oldDom, parentDom) { return oldDom; } else if (parentVNode._dom != oldDom) { - if (oldDom && parentVNode.type && !parentDom.contains(oldDom)) { + if (oldDom && parentVNode.type && !oldDom.parentNode) { oldDom = getDomSibling(parentVNode); } parentDom.insertBefore(parentVNode._dom, oldDom || null); diff --git a/src/index.d.ts b/src/index.d.ts index 287d575c53..51321916f9 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -289,7 +289,6 @@ interface ContainerNode { readonly firstChild: ContainerNode | null; readonly childNodes: ArrayLike; - contains(other: ContainerNode | null): boolean; insertBefore(node: ContainerNode, child: ContainerNode | null): ContainerNode; appendChild(node: ContainerNode): ContainerNode; removeChild(child: ContainerNode): ContainerNode;