mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Allow node.contains(null) (false), per spec
This commit is contained in:
@@ -210,3 +210,16 @@
|
|||||||
testing.expectEqual('HTMLDivElement', disconnectedChild.getRootNode().__proto__.constructor.name);
|
testing.expectEqual('HTMLDivElement', disconnectedChild.getRootNode().__proto__.constructor.name);
|
||||||
testing.expectEqual('HTMLDivElement', disconnectedChild.getRootNode({ composed: true }).__proto__.constructor.name);
|
testing.expectEqual('HTMLDivElement', disconnectedChild.getRootNode({ composed: true }).__proto__.constructor.name);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div id=contains><div id=other></div></div>
|
||||||
|
<script id=contains>
|
||||||
|
{
|
||||||
|
const d1 = $('#contains');
|
||||||
|
const d2 = $('#other');
|
||||||
|
testing.expectEqual(false, d1.contains(null));
|
||||||
|
testing.expectEqual(true, d1.contains(d1));
|
||||||
|
testing.expectEqual(false, d2.contains(d1));
|
||||||
|
testing.expectEqual(true, d1.contains(d2));
|
||||||
|
testing.expectEqual(false, d1.contains(p1));
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -413,7 +413,9 @@ pub fn getRootNode(self: *Node, opts_: ?GetRootNodeOpts) *Node {
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn contains(self: *const Node, child: *const Node) bool {
|
pub fn contains(self: *const Node, child_: ?*const Node) bool {
|
||||||
|
const child = child_ orelse return false;
|
||||||
|
|
||||||
if (self == child) {
|
if (self == child) {
|
||||||
// yes, this is correct
|
// yes, this is correct
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user