Skip to content

Commit b9ae24c

Browse files
committed
add window.queueMicrotask
1 parent d6ace3f commit b9ae24c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/browser/html/window.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ pub const Window = struct {
190190
return page.loop.cancel(kv.value.loop_id);
191191
}
192192

193-
// TODO handle callback arguments.
194193
pub fn _setTimeout(self: *Window, cbk: Function, delay: ?u32, page: *Page) !u32 {
195194
return self.createTimeout(cbk, delay, page, .{});
196195
}
@@ -210,6 +209,10 @@ pub const Window = struct {
210209
return page.loop.cancel(kv.value.loop_id);
211210
}
212211

212+
pub fn _queueMicrotask(self: *Window, cbk: Function, page: *Page) !u32 {
213+
return self.createTimeout(cbk, 0, page, .{});
214+
}
215+
213216
pub fn _matchMedia(_: *const Window, media: []const u8, page: *Page) !MediaQueryList {
214217
return .{
215218
.matches = false, // TODO?
@@ -468,4 +471,9 @@ test "Browser.HTML.Window" {
468471
.{ "scroll", "true" },
469472
.{ "scrollend", "true" },
470473
}, .{});
474+
475+
try runner.testCases(&.{
476+
.{ "var qm = false; window.queueMicrotask(() => {qm = true });", null },
477+
.{ "qm", "true" },
478+
}, .{});
471479
}

0 commit comments

Comments
 (0)