node: add normalize method (NO TEST)

Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
Francis Bouvier
2023-09-27 14:55:36 +02:00
parent 2e3d1220f6
commit 9b544db2a9
2 changed files with 14 additions and 0 deletions

View File

@@ -169,6 +169,10 @@ pub const Node = struct {
return parser.nodeIsEqualNode(self, other); return parser.nodeIsEqualNode(self, other);
} }
pub fn _normalize(self: *parser.Node) void {
return parser.nodeNormalize(self);
}
pub fn _removeChild(self: *parser.Node, child: *parser.Node) Union { pub fn _removeChild(self: *parser.Node, child: *parser.Node) Union {
const res = parser.nodeRemoveChild(self, child); const res = parser.nodeRemoveChild(self, child);
return Node.toInterface(res); return Node.toInterface(res);
@@ -349,6 +353,12 @@ pub fn testExecFn(
}; };
try checkCases(js_env, &node_is_equal_node); try checkCases(js_env, &node_is_equal_node);
var node_normalize = [_]Case{
// TODO: no test
.{ .src = "link.normalize()", .ex = "undefined" },
};
try checkCases(js_env, &node_normalize);
var node_remove_child = [_]Case{ var node_remove_child = [_]Case{
.{ .src = "content.removeChild(append) !== undefined", .ex = "true" }, .{ .src = "content.removeChild(append) !== undefined", .ex = "true" },
.{ .src = "content.lastChild.__proto__.constructor.name !== 'HTMLHeadingElement'", .ex = "true" }, .{ .src = "content.lastChild.__proto__.constructor.name !== 'HTMLHeadingElement'", .ex = "true" },

View File

@@ -377,6 +377,10 @@ pub fn nodeIsEqualNode(node: *Node, other: *Node) bool {
return res; return res;
} }
pub fn nodeNormalize(node: *Node) void {
_ = nodeVtable(node).dom_node_normalize.?(node);
}
pub fn nodeRemoveChild(node: *Node, child: *Node) *Node { pub fn nodeRemoveChild(node: *Node, child: *Node) *Node {
var res: ?*Node = undefined; var res: ?*Node = undefined;
_ = nodeVtable(node).dom_node_remove_child.?(node, child, &res); _ = nodeVtable(node).dom_node_remove_child.?(node, child, &res);