Skip to content

Commit

Permalink
Merge pull request #777 from CSchulz/patch-6
Browse files Browse the repository at this point in the history
#776@patch: Add self equality check in node.contains method.
  • Loading branch information
capricorn86 committed Feb 24, 2023
2 parents 4ac24eb + 2df12ce commit ca0d075
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 ca0d075

Please sign in to comment.