mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 00:08:59 +00:00
node: add isEqualNode method (TEST NOT WORKING)
Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
@@ -163,6 +163,11 @@ pub const Node = struct {
|
|||||||
// TODO: namespace is not an optional parameter, but can be null.
|
// TODO: namespace is not an optional parameter, but can be null.
|
||||||
return parser.nodeIsDefaultNamespace(self, namespace);
|
return parser.nodeIsDefaultNamespace(self, namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn _isEqualNode(self: *parser.Node, other: *parser.Node) bool {
|
||||||
|
// TODO: other is not an optional parameter, but can be null.
|
||||||
|
return parser.nodeIsEqualNode(self, other);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Types = generate.Tuple(.{
|
pub const Types = generate.Tuple(.{
|
||||||
@@ -323,4 +328,14 @@ pub fn testExecFn(
|
|||||||
.{ .src = "link.isDefaultNamespace('false')", .ex = "false" },
|
.{ .src = "link.isDefaultNamespace('false')", .ex = "false" },
|
||||||
};
|
};
|
||||||
try checkCases(js_env, &node_is_default_namespace);
|
try checkCases(js_env, &node_is_default_namespace);
|
||||||
|
|
||||||
|
var node_is_equal_node = [_]Case{
|
||||||
|
.{ .src = "let equal1 = document.createElement('a')", .ex = "undefined" },
|
||||||
|
.{ .src = "let equal2 = document.createElement('a')", .ex = "undefined" },
|
||||||
|
.{ .src = "equal1.textContent = 'is equal'", .ex = "is equal" },
|
||||||
|
.{ .src = "equal2.textContent = 'is equal'", .ex = "is equal" },
|
||||||
|
// TODO: does not seems to work
|
||||||
|
// .{ .src = "equal1.isEqualNode(equal2)", .ex = "true" },
|
||||||
|
};
|
||||||
|
try checkCases(js_env, &node_is_equal_node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,6 +371,12 @@ pub fn nodeIsDefaultNamespace(node: *Node, namespace: []const u8) bool {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn nodeIsEqualNode(node: *Node, other: *Node) bool {
|
||||||
|
var res: bool = undefined;
|
||||||
|
_ = nodeVtable(node).dom_node_is_equal.?(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