mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
dom: implement HTMLCollection
We can't simply use the libdom dom_document_get_elements_by_tag_name
because it follows an old version of the specifications and returns a
NodeList.
Since
190700b7c1
the spec changed in favor of returning an HTMLCollection.
So I'm trying to re-implement the HTMLCollection in zig.
This commit is contained in:
@@ -765,6 +765,18 @@ pub inline fn documentGetElementsByTagName(doc: *Document, tagname: []const u8)
|
||||
return nlist.?;
|
||||
}
|
||||
|
||||
// documentGetDocumentElement returns the root document element.
|
||||
pub inline fn documentGetDocumentElement(doc: *Document) *Element {
|
||||
var elem: ?*Element = undefined;
|
||||
_ = documentVtable(doc).dom_document_get_document_element.?(doc, &elem);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user