HTMLDocument: implement all getter

This commit is contained in:
Pierre Tachoire
2024-01-05 10:28:09 +01:00
parent fce9e44407
commit c73ecb5e0d
2 changed files with 17 additions and 0 deletions

View File

@@ -167,6 +167,18 @@ pub fn HTMLCollectionByName(
};
}
pub fn HTMLCollectionAll(
root: ?*parser.Node,
include_root: bool,
) !HTMLCollection {
return HTMLCollection{
.root = root,
.walker = Walker{ .walkerDepthFirst = .{} },
.matcher = Matcher{ .matchTrue = .{} },
.include_root = include_root,
};
}
pub fn HTMLCollectionChildren(
root: ?*parser.Node,
include_root: bool,

View File

@@ -138,6 +138,10 @@ pub const HTMLDocument = struct {
return try collection.HTMLCollectionByAnchors(try rootNode(self), false);
}
pub fn get_all(self: *parser.DocumentHTML) !collection.HTMLCollection {
return try collection.HTMLCollectionAll(try rootNode(self), true);
}
pub fn get_currentScript(_: *parser.DocumentHTML) !?*parser.Element {
return null;
}
@@ -219,6 +223,7 @@ pub fn testExecFn(
.{ .src = "document.links.length", .ex = "1" },
.{ .src = "document.applets.length", .ex = "0" },
.{ .src = "document.anchors.length", .ex = "0" },
.{ .src = "document.all.length", .ex = "8" },
.{ .src = "document.currentScript", .ex = "null" },
};
try checkCases(js_env, &getters);