mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
node: add isSameNode method
Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
@@ -169,6 +169,12 @@ pub const Node = struct {
|
||||
return parser.nodeIsEqualNode(self, other);
|
||||
}
|
||||
|
||||
pub fn _isSameNode(self: *parser.Node, other: *parser.Node) bool {
|
||||
// TODO: other is not an optional parameter, but can be null.
|
||||
// NOTE: there is no need to use isSameNode(); instead use the === strict equality operator
|
||||
return parser.nodeIsSameNode(self, other);
|
||||
}
|
||||
|
||||
pub fn _normalize(self: *parser.Node) void {
|
||||
return parser.nodeNormalize(self);
|
||||
}
|
||||
@@ -353,6 +359,11 @@ pub fn testExecFn(
|
||||
};
|
||||
try checkCases(js_env, &node_is_equal_node);
|
||||
|
||||
var node_is_same_node = [_]Case{
|
||||
.{ .src = "document.body.isSameNode(document.body)", .ex = "true" },
|
||||
};
|
||||
try checkCases(js_env, &node_is_same_node);
|
||||
|
||||
var node_normalize = [_]Case{
|
||||
// TODO: no test
|
||||
.{ .src = "link.normalize()", .ex = "undefined" },
|
||||
|
||||
@@ -377,6 +377,12 @@ pub fn nodeIsEqualNode(node: *Node, other: *Node) bool {
|
||||
return res;
|
||||
}
|
||||
|
||||
pub fn nodeIsSameNode(node: *Node, other: *Node) bool {
|
||||
var res: bool = undefined;
|
||||
_ = nodeVtable(node).dom_node_is_same.?(node, other, &res);
|
||||
return res;
|
||||
}
|
||||
|
||||
pub fn nodeNormalize(node: *Node) void {
|
||||
_ = nodeVtable(node).dom_node_normalize.?(node);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user