dom: implement NodeList

This commit is contained in:
Pierre Tachoire
2023-12-14 11:01:39 +01:00
parent 2bfc138f91
commit 8435f781ee
4 changed files with 51 additions and 0 deletions

32
src/dom/nodelist.zig Normal file
View File

@@ -0,0 +1,32 @@
const std = @import("std");
const parser = @import("../netsurf.zig");
const jsruntime = @import("jsruntime");
const NodeUnion = @import("node.zig").Union;
const Node = @import("node.zig").Node;
const DOMException = @import("exceptions.zig").DOMException;
// WEB IDL https://dom.spec.whatwg.org/#nodelist
pub const NodeList = struct {
pub const Self = parser.NodeList;
pub const mem_guarantied = true;
pub const Exception = DOMException;
pub fn get_length(self: *parser.NodeList) !u32 {
return try parser.nodeListLength(self);
}
pub fn _item(self: *parser.NodeList, index: u32) !?NodeUnion {
const n = try parser.nodeListItem(self, index);
if (n == null) return null;
return try Node.toInterface(n.?);
}
// TODO _symbol_iterator
// TODO implement postAttach
};