dom: create elementToNode helper

This commit is contained in:
Pierre Tachoire
2023-11-17 15:11:00 +01:00
parent 3ca6a4a74e
commit 18bfaf8b55
2 changed files with 7 additions and 7 deletions

View File

@@ -621,6 +621,11 @@ pub fn elementGetAttribute(elem: *Element, name: []const u8) ?[]const u8 {
return stringToData(s.?);
}
// elementToNode is an helper to convert an element to a node.
pub inline fn elementToNode(e: *Element) *Node {
return @as(*Node, @ptrCast(e));
}
// ElementHTML
pub const ElementHTML = c.dom_html_element;
@@ -741,11 +746,6 @@ pub inline fn documentGetDocumentElement(doc: *Document) *Element {
return elem.?;
}
pub inline fn documentGetDocumentNode(doc: *Document) *Node {
const res = documentGetDocumentElement(doc);
return @as(*Node, @ptrCast(res));
}
pub inline fn documentCreateElement(doc: *Document, tag_name: []const u8) *Element {
var elem: ?*Element = undefined;
_ = documentVtable(doc).dom_document_create_element.?(doc, stringFromData(tag_name), &elem);