From 1c4edf7c95fdd85df9fb7e59e0d3e37ea93caddf Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Mon, 27 Nov 2023 11:53:52 +0100 Subject: [PATCH] dom: implement document constructor --- src/dom/document.zig | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/dom/document.zig b/src/dom/document.zig index ef3f4831..a2a74810 100644 --- a/src/dom/document.zig +++ b/src/dom/document.zig @@ -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| {