mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
fix Node.contains
This commit is contained in:
@@ -77,6 +77,8 @@
|
||||
</script>
|
||||
|
||||
<script id=contains>
|
||||
testing.expectEqual(true, document.contains(document));
|
||||
testing.expectEqual(true, $('#d1').contains($('#d1')));
|
||||
testing.expectEqual(true, document.contains($('#d1')));
|
||||
testing.expectEqual(true, document.contains($('#p1')));
|
||||
testing.expectEqual(true, document.contains($('#p2')));
|
||||
|
||||
@@ -224,6 +224,11 @@ pub fn getRootNode(self: *const Node, opts_: ?GetRootNodeOpts) *const Node {
|
||||
}
|
||||
|
||||
pub fn contains(self: *const Node, child: *const Node) bool {
|
||||
if (self == child) {
|
||||
// yes, this is correct
|
||||
return true;
|
||||
}
|
||||
|
||||
var parent = child._parent;
|
||||
while (parent) |p| {
|
||||
if (p == self) {
|
||||
|
||||
Reference in New Issue
Block a user