mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
node: add hasChildnodes method
Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
@@ -150,6 +150,10 @@ pub const Node = struct {
|
||||
_ = self;
|
||||
@panic("Not implemented node.getRootNode()");
|
||||
}
|
||||
|
||||
pub fn _hasChildNodes(self: *parser.Node) bool {
|
||||
return parser.nodeHasChildNodes(self);
|
||||
}
|
||||
};
|
||||
|
||||
pub const Types = generate.Tuple(.{
|
||||
@@ -290,4 +294,10 @@ pub fn testExecFn(
|
||||
.{ .src = "text.contains(link)", .ex = "false" },
|
||||
};
|
||||
try checkCases(js_env, &node_contains);
|
||||
|
||||
var node_has_child_nodes = [_]Case{
|
||||
.{ .src = "link.hasChildNodes()", .ex = "true" },
|
||||
.{ .src = "text.hasChildNodes()", .ex = "false" },
|
||||
};
|
||||
try checkCases(js_env, &node_has_child_nodes);
|
||||
}
|
||||
|
||||
@@ -352,6 +352,12 @@ pub fn nodeContains(node: *Node, other: *Node) bool {
|
||||
return res;
|
||||
}
|
||||
|
||||
pub fn nodeHasChildNodes(node: *Node) bool {
|
||||
var res: bool = undefined;
|
||||
_ = nodeVtable(node).dom_node_has_child_nodes.?(node, &res);
|
||||
return res;
|
||||
}
|
||||
|
||||
// CharacterData
|
||||
pub const CharacterData = c.dom_characterdata;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user