characterdata: add length getter

Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
Francis Bouvier
2023-09-28 19:48:42 +02:00
parent 9c8d1082a3
commit 51f1271496
2 changed files with 17 additions and 0 deletions

View File

@@ -19,6 +19,12 @@ pub const CharacterData = struct {
// JS funcs
// --------
// Read attributes
pub fn get_length(self: *parser.CharacterData) u32 {
return parser.characterDataLength(self);
}
// Read/Write attributes
pub fn get_data(self: *parser.CharacterData) []const u8 {
@@ -58,4 +64,9 @@ pub fn testExecFn(
.{ .src = "cdata_t.data = 'OK'", .ex = "OK" },
};
try checkCases(js_env, &set_data);
var get_length = [_]Case{
.{ .src = "cdata_t.length === 2", .ex = "true" },
};
try checkCases(js_env, &get_length);
}