dom: add document.characterSet with hardcoded value

This commit is contained in:
Pierre Tachoire
2023-11-21 09:30:36 +01:00
parent e4d1b1d921
commit 4ae0c0c5af

View File

@@ -34,6 +34,22 @@ pub const Document = struct {
return Element.toInterface(e);
}
// TODO implement characterSet
pub fn get_characterSet(self: *parser.Document) []const u8 {
_ = self;
return "UTF-8";
}
// alias of get_characterSet
pub fn get_charset(self: *parser.Document) []const u8 {
return get_characterSet(self);
}
// alias of get_characterSet
pub fn get_inputEncoding(self: *parser.Document) []const u8 {
return get_characterSet(self);
}
pub fn get_doctype(self: *parser.Document) ?*parser.DocumentType {
return parser.documentGetDoctype(self);
}
@@ -123,6 +139,13 @@ pub fn testExecFn(
};
try checkCases(js_env, &getDocumentElement);
var getCharacterSet = [_]Case{
.{ .src = "document.characterSet", .ex = "UTF-8" },
.{ .src = "document.charset", .ex = "UTF-8" },
.{ .src = "document.inputEncoding", .ex = "UTF-8" },
};
try checkCases(js_env, &getCharacterSet);
const tags = comptime parser.Tag.all();
comptime var createElements: [(tags.len) * 2]Case = undefined;
inline for (tags, 0..) |tag, i| {