node: add removechild method

Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
Francis Bouvier
2023-09-27 11:08:37 +02:00
parent 012622fc5f
commit 08ded87e02
2 changed files with 17 additions and 0 deletions

View File

@@ -168,6 +168,11 @@ pub const Node = struct {
// TODO: other is not an optional parameter, but can be null.
return parser.nodeIsEqualNode(self, other);
}
pub fn _removeChild(self: *parser.Node, child: *parser.Node) Union {
const res = parser.nodeRemoveChild(self, child);
return Node.toInterface(res);
}
};
pub const Types = generate.Tuple(.{
@@ -338,4 +343,10 @@ pub fn testExecFn(
// .{ .src = "equal1.isEqualNode(equal2)", .ex = "true" },
};
try checkCases(js_env, &node_is_equal_node);
var node_remove_child = [_]Case{
.{ .src = "content.removeChild(append) !== undefined", .ex = "true" },
.{ .src = "content.lastChild.__proto__.constructor.name !== 'HTMLHeadingElement'", .ex = "true" },
};
try checkCases(js_env, &node_remove_child);
}