dom: implement document constructor

This commit is contained in:
Pierre Tachoire
2023-11-27 11:53:52 +01:00
parent 7bd4729d3f
commit 1c4edf7c95

View File

@@ -22,10 +22,9 @@ pub const Document = struct {
pub const prototype = *Node;
pub const mem_guarantied = true;
// pub fn constructor() *parser.Document {
// // TODO
// return .{};
// }
pub fn constructor() *parser.Document {
return parser.domImplementationCreateHTMLDocument(null);
}
// JS funcs
// --------
@@ -208,6 +207,16 @@ pub fn testExecFn(
};
try checkCases(js_env, &getImplementation);
var new = [_]Case{
.{ .src = "let d = new Document()", .ex = "undefined" },
.{ .src = "d.characterSet", .ex = "UTF-8" },
.{ .src = "d.URL", .ex = "about:blank" },
.{ .src = "d.documentURI", .ex = "about:blank" },
.{ .src = "d.compatMode", .ex = "CSS1Compat" },
.{ .src = "d.contentType", .ex = "text/html" },
};
try checkCases(js_env, &new);
const tags = comptime parser.Tag.all();
comptime var createElements: [(tags.len) * 2]Case = undefined;
inline for (tags, 0..) |tag, i| {