Skip to content

Commit

Permalink
fix(moc-doc): make Node.contains() return true for self (#3150)
Browse files Browse the repository at this point in the history
`Node.contains()` should return `true` if the passed node is the 
parent/context node.  [The wording in the spec](https://dom.spec.whatwg.org/#dom-node-contains) is that it
should return `true` if the passed node is an "inclusive descendant",
which differs from a regular "descendant" in that it includes the 
object itself (not just the child nodes).
  • Loading branch information
kevinleedrum committed Dec 3, 2021
1 parent b2eb083 commit f164407
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mock-doc/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export class MockNode {
}

contains(otherNode: MockNode) {
if (otherNode === this) {
return true;
}
return this.childNodes.includes(otherNode);
}

Expand Down

0 comments on commit f164407

Please sign in to comment.