mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 07:31:47 +00:00
Add missing TokenList APIs
Add value setter, keys(), values(), entries() and forEach(). Like nodelist, forEach still doesn't support `this` arg (gotta think about how to do this). I think these iterable methods are missing in a few places, so I added a generic Entries iterator and a generic Iterable. jsruntime will now map a Zig tuple to a JS array.
This commit is contained in:
@@ -691,6 +691,19 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
|
||||
return value.func.toValue();
|
||||
}
|
||||
|
||||
if (s.is_tuple) {
|
||||
// return the tuple struct as an array
|
||||
var js_arr = v8.Array.init(isolate, @intCast(s.fields.len));
|
||||
var js_obj = js_arr.castTo(v8.Object);
|
||||
inline for (s.fields, 0..) |f, i| {
|
||||
const js_val = try zigValueToJs(templates, isolate, context, @field(value, f.name));
|
||||
if (js_obj.setValueAtIndex(context, @intCast(i), js_val) == false) {
|
||||
return error.FailedToCreateArray;
|
||||
}
|
||||
}
|
||||
return js_obj.toValue();
|
||||
}
|
||||
|
||||
// return the struct as a JS object
|
||||
const js_obj = v8.Object.init(isolate);
|
||||
inline for (s.fields) |f| {
|
||||
|
||||
Reference in New Issue
Block a user