mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 08:18:59 +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.
|
// TODO: other is not an optional parameter, but can be null.
|
||||||
return parser.nodeIsEqualNode(self, other);
|
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(.{
|
pub const Types = generate.Tuple(.{
|
||||||
@@ -338,4 +343,10 @@ pub fn testExecFn(
|
|||||||
// .{ .src = "equal1.isEqualNode(equal2)", .ex = "true" },
|
// .{ .src = "equal1.isEqualNode(equal2)", .ex = "true" },
|
||||||
};
|
};
|
||||||
try checkCases(js_env, &node_is_equal_node);
|
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;
|
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
|
// CharacterData
|
||||||
pub const CharacterData = c.dom_characterdata;
|
pub const CharacterData = c.dom_characterdata;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user