mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
node: add removechild method
Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -377,6 +377,12 @@ pub fn nodeIsEqualNode(node: *Node, other: *Node) bool {
|
||||
return res;
|
||||
}
|
||||
|
||||
pub fn nodeRemoveChild(node: *Node, child: *Node) *Node {
|
||||
var res: ?*Node = undefined;
|
||||
_ = nodeVtable(node).dom_node_remove_child.?(node, child, &res);
|
||||
return res.?;
|
||||
}
|
||||
|
||||
// CharacterData
|
||||
pub const CharacterData = c.dom_characterdata;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user