Skip to content

Commit 1a04ebc

Browse files
committed
fix Node.contains
1 parent 59bbfc4 commit 1a04ebc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/browser/tests/node/child_nodes.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
</script>
7878

7979
<script id=contains>
80+
testing.expectEqual(true, document.contains(document));
81+
testing.expectEqual(true, $('#d1').contains($('#d1')));
8082
testing.expectEqual(true, document.contains($('#d1')));
8183
testing.expectEqual(true, document.contains($('#p1')));
8284
testing.expectEqual(true, document.contains($('#p2')));

src/browser/webapi/Node.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ pub fn getRootNode(self: *const Node, opts_: ?GetRootNodeOpts) *const Node {
224224
}
225225

226226
pub fn contains(self: *const Node, child: *const Node) bool {
227+
if (self == child) {
228+
// yes, this is correct
229+
return true;
230+
}
231+
227232
var parent = child._parent;
228233
while (parent) |p| {
229234
if (p == self) {

0 commit comments

Comments
 (0)