node: add lookupPrefix method (NOT TESTED)

Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
Francis Bouvier
2023-09-28 18:17:04 +02:00
parent 24dc25391e
commit 8c0279bd1b
2 changed files with 20 additions and 0 deletions

View File

@@ -175,6 +175,11 @@ pub const Node = struct {
return parser.nodeIsSameNode(self, other);
}
pub fn _lookupPrefix(self: *parser.Node, namespace: ?[]const u8) ?[]const u8 {
// TODO: other is not an optional parameter, but can be null.
return parser.nodeLookupPrefix(self, namespace);
}
pub fn _normalize(self: *parser.Node) void {
return parser.nodeNormalize(self);
}

View File

@@ -383,6 +383,21 @@ pub fn nodeIsSameNode(node: *Node, other: *Node) bool {
return res;
}
pub fn nodeLookupPrefix(node: *Node, namespace: ?[]const u8) ?[]const u8 {
if (namespace == null) {
return null;
}
if (std.mem.eql(u8, namespace.?, "")) {
return null;
}
var s: ?*String = undefined;
_ = nodeVtable(node).dom_node_lookup_prefix.?(node, stringFromData(namespace.?), &s);
if (s == null) {
return null;
}
return stringToData(s.?);
}
pub fn nodeNormalize(node: *Node) void {
_ = nodeVtable(node).dom_node_normalize.?(node);
}