mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 07:31:47 +00:00
dom: implement NodeList
This commit is contained in:
32
src/dom/nodelist.zig
Normal file
32
src/dom/nodelist.zig
Normal 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
|
||||
};
|
||||
Reference in New Issue
Block a user