mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +00:00
node: add contains method
Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
@@ -141,6 +141,10 @@ pub const Node = struct {
|
|||||||
_ = self;
|
_ = self;
|
||||||
@panic("Not implemented node.compareDocumentPosition()");
|
@panic("Not implemented node.compareDocumentPosition()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn _contains(self: *parser.Node, other: *parser.Node) bool {
|
||||||
|
return parser.nodeContains(self, other);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Types = generate.Tuple(.{
|
pub const Types = generate.Tuple(.{
|
||||||
@@ -275,4 +279,10 @@ pub fn testExecFn(
|
|||||||
.{ .src = "clone_deep.firstChild.nodeName === '#text'", .ex = "true" },
|
.{ .src = "clone_deep.firstChild.nodeName === '#text'", .ex = "true" },
|
||||||
};
|
};
|
||||||
try checkCases(js_env, &node_clone);
|
try checkCases(js_env, &node_clone);
|
||||||
|
|
||||||
|
var node_contains = [_]Case{
|
||||||
|
.{ .src = "link.contains(text)", .ex = "true" },
|
||||||
|
.{ .src = "text.contains(link)", .ex = "false" },
|
||||||
|
};
|
||||||
|
try checkCases(js_env, &node_contains);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,6 +346,12 @@ pub fn nodeCloneNode(node: *Node, is_deep: bool) *Node {
|
|||||||
return res.?;
|
return res.?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn nodeContains(node: *Node, other: *Node) bool {
|
||||||
|
var res: bool = undefined;
|
||||||
|
_ = c._dom_node_contains(node, other, &res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// CharacterData
|
// CharacterData
|
||||||
pub const CharacterData = c.dom_characterdata;
|
pub const CharacterData = c.dom_characterdata;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user