@@ -11,6 +11,7 @@ const Location = @import("Location.zig");
1111const Fetch = @import ("net/Fetch.zig" );
1212const EventTarget = @import ("EventTarget.zig" );
1313const ErrorEvent = @import ("event/ErrorEvent.zig" );
14+ const MediaQueryList = @import ("css/MediaQueryList.zig" );
1415const storage = @import ("storage/storage.zig" );
1516
1617const Window = @This ();
@@ -135,6 +136,13 @@ pub fn cancelAnimationFrame(self: *Window, id: u32) void {
135136 sc .removed = true ;
136137}
137138
139+ pub fn matchMedia (_ : * const Window , query : []const u8 , page : * Page ) ! * MediaQueryList {
140+ return page ._factory .eventTarget (MediaQueryList {
141+ ._proto = undefined ,
142+ ._media = try page .dupeString (query ),
143+ });
144+ }
145+
138146pub fn btoa (_ : * const Window , input : []const u8 , page : * Page ) ! []const u8 {
139147 const encoded_len = std .base64 .standard .Encoder .calcSize (input .len );
140148 const encoded = try page .call_arena .alloc (u8 , encoded_len );
@@ -266,6 +274,7 @@ pub const JsApi = struct {
266274 pub const clearImmediate = bridge .function (Window .clearImmediate , .{});
267275 pub const requestAnimationFrame = bridge .function (Window .requestAnimationFrame , .{});
268276 pub const cancelAnimationFrame = bridge .function (Window .cancelAnimationFrame , .{});
277+ pub const matchMedia = bridge .function (Window .matchMedia , .{});
269278 pub const btoa = bridge .function (Window .btoa , .{});
270279 pub const atob = bridge .function (Window .atob , .{});
271280};
0 commit comments