Skip to content

Commit

Permalink
Remove contains with a simple parentNode check
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Feb 14, 2025
1 parent 9bb7843 commit ffd0d31
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion compat/src/portals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ interface ContainerNode {
readonly firstChild: ContainerNode | null;
readonly childNodes: ArrayLike<ContainerNode>;

contains(other: ContainerNode | null): boolean;
insertBefore(node: ContainerNode, child: ContainerNode | null): ContainerNode;
appendChild(node: ContainerNode): ContainerNode;
removeChild(child: ContainerNode): ContainerNode;
Expand Down

0 comments on commit ffd0d31

Please sign in to comment.