dom: add HTMLCollection

This commit is contained in:
Pierre Tachoire
2023-10-24 17:12:59 +02:00
parent a238eed065
commit 2e40837f0d
3 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
const std = @import("std");
const parser = @import("../netsurf.zig");
const jsruntime = @import("jsruntime");
const Element = @import("element.zig").Element;
// WEB IDL https://dom.spec.whatwg.org/#htmlcollection
pub const HTMLCollection = struct {
pub const Self = parser.HTMLCollection;
pub const mem_guarantied = true;
// JS funcs
// --------
pub fn _get_length(self: *parser.HTMLCollection) u32 {
return parser.HTMLCollectionLength(self);
}
pub fn _item(self: *parser.HTMLCollection, index: u32) ?*parser.Element {
return parser.HTMLCollectionItem(self, index);
}
pub fn _namedItem(self: *parser.HTMLCollection, name: []const u8) ?*parser.Element {
return parser.HTMLCollectionNamedItem(self, name);
}
};

View File

@@ -14,6 +14,7 @@ const EventTarget = @import("event_target.zig").EventTarget;
const CData = @import("character_data.zig");
const Element = @import("element.zig").Element;
const Document = @import("document.zig").Document;
const HTMLCollection = @import("html_collection.zig").HTMLCollection;
// HTML
const HTML = @import("../html/html.zig");
@@ -25,6 +26,7 @@ pub const Interfaces = generate.Tuple(.{
CData.Interfaces,
Element,
Document,
HTMLCollection,
HTML.Interfaces,
});