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