Skip to content

Commit

Permalink
capricorn86#776@patch: Add self equality check in node.contains method.
Browse files Browse the repository at this point in the history
  • Loading branch information
CSchulz committed Feb 22, 2023
1 parent e1fb3ee commit c439cc1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/happy-dom/src/nodes/node/Node.ts
Expand Up @@ -233,6 +233,9 @@ export default class Node extends EventTarget implements INode {
* @returns "true" if this node contains the other node.
*/
public contains(otherNode: INode): boolean {
if (this === otherNode) {
return true;
}
for (const childNode of this.childNodes) {
if (childNode === otherNode || childNode.contains(otherNode)) {
return true;
Expand Down

0 comments on commit c439cc1

Please sign in to comment.