diff --git a/CHANGES.md b/CHANGES.md index debef540f9..c0c46e3957 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -40,6 +40,7 @@ * Compiler: deadcode elimination of cyclic values (#1978) * Compiler: directly write Wasm binary modules (#2000, #2003) * Compiler: rewrote inlining pass (#1935, #2018, #2027) +* Library: add Dom_html.window.matchMedia & Dom_html.mediaQueryList (#2017) ## Bug fixes * Compiler: fix stack overflow issues with double translation (#1869) diff --git a/lib/js_of_ocaml/dom_html.ml b/lib/js_of_ocaml/dom_html.ml index 15d255be59..7751d08eab 100644 --- a/lib/js_of_ocaml/dom_html.ml +++ b/lib/js_of_ocaml/dom_html.ml @@ -464,6 +464,14 @@ and toggleEvent = object method oldState : js_string t readonly_prop end +and mediaQueryListEvent = object + inherit event + + method matches : js_string t readonly_prop + + method media : bool t readonly_prop +end + and dataTransfer = object method dropEffect : js_string t prop @@ -2312,6 +2320,16 @@ class type _URL = object method revokeObjectURL : js_string t -> unit meth end +class type mediaQueryList = object + method media : js_string t prop + + method matches : bool readonly_prop + + method onchange : (mediaQueryList t, mediaQueryListEvent t) event_listener prop + + inherit eventTarget +end + class type window = object inherit eventTarget @@ -2428,6 +2446,8 @@ class type window = object method _URL : _URL t readonly_prop method devicePixelRatio : number_t readonly_prop + + method matchMedia : js_string t -> mediaQueryList t meth end let window : window t = Js.Unsafe.global diff --git a/lib/js_of_ocaml/dom_html.mli b/lib/js_of_ocaml/dom_html.mli index 1fcf0cc7e8..41d09dad88 100644 --- a/lib/js_of_ocaml/dom_html.mli +++ b/lib/js_of_ocaml/dom_html.mli @@ -477,6 +477,14 @@ and toggleEvent = object method oldState : js_string t readonly_prop end +and mediaQueryListEvent = object + inherit event + + method matches : js_string t readonly_prop + + method media : bool t readonly_prop +end + and dataTransfer = object method dropEffect : js_string t prop @@ -2164,6 +2172,16 @@ class type _URL = object method revokeObjectURL : js_string t -> unit meth end +class type mediaQueryList = object + method media : js_string t prop + + method matches : bool readonly_prop + + method onchange : (mediaQueryList t, mediaQueryListEvent t) event_listener prop + + inherit eventTarget +end + (** Specification of window objects *) class type window = object inherit eventTarget @@ -2285,6 +2303,8 @@ class type window = object method _URL : _URL t readonly_prop method devicePixelRatio : number_t readonly_prop + + method matchMedia : js_string t -> mediaQueryList t meth end val window : window t