dom: implement document.createComment

This commit is contained in:
Pierre Tachoire
2023-12-07 16:30:33 +01:00
parent 94876d01f1
commit 24ec5f554d
2 changed files with 16 additions and 0 deletions

View File

@@ -137,6 +137,10 @@ pub const Document = struct {
return try parser.documentCreateCDATASection(self, data);
}
pub fn _createComment(self: *parser.Document, data: []const u8) !*parser.Comment {
return try parser.documentCreateComment(self, data);
}
pub fn deinit(_: *parser.Document, _: std.mem.Allocator) void {}
};
@@ -244,6 +248,11 @@ pub fn testExecFn(
};
try checkCases(js_env, &createCDATASection);
var createComment = [_]Case{
.{ .src = "document.createComment('foo')", .ex = "[object Comment]" },
};
try checkCases(js_env, &createComment);
const tags = comptime parser.Tag.all();
comptime var createElements: [(tags.len) * 2]Case = undefined;
inline for (tags, 0..) |tag, i| {