From c51a1b119a2e6d7f148295a74c0e98b2dfe0e2c9 Mon Sep 17 00:00:00 2001 From: Kevin Lee Drum Date: Fri, 19 Nov 2021 11:46:33 -0500 Subject: [PATCH 1/2] Fix Node.contains mock to match itself The `Node.contains` method 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). --- src/mock-doc/node.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mock-doc/node.ts b/src/mock-doc/node.ts index 3617e7a605b..1fd4e6c9142 100644 --- a/src/mock-doc/node.ts +++ b/src/mock-doc/node.ts @@ -138,6 +138,7 @@ export class MockNode { } contains(otherNode: MockNode) { + if (otherNode === this) return true; return this.childNodes.includes(otherNode); } From d29d568a06bee1fbc5324e6fbbd7131632dd5f42 Mon Sep 17 00:00:00 2001 From: Kevin Lee Drum Date: Fri, 3 Dec 2021 11:05:25 -0500 Subject: [PATCH 2/2] Put return statement on its own line Co-authored-by: Ryan Waskiewicz --- src/mock-doc/node.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mock-doc/node.ts b/src/mock-doc/node.ts index 1fd4e6c9142..4fb13229117 100644 --- a/src/mock-doc/node.ts +++ b/src/mock-doc/node.ts @@ -138,7 +138,9 @@ export class MockNode { } contains(otherNode: MockNode) { - if (otherNode === this) return true; + if (otherNode === this) { + return true; + } return this.childNodes.includes(otherNode); }