Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
===== dev =====
* Add toggle event for details elements.

===== 10.4.1 =====
* Update to OCaml 5.2 (thanks to Kate Deplaix)

Expand Down
1 change: 1 addition & 0 deletions src/lib/eliom_content.client.mli
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ module Html : sig
val onreturn : ('a, Dom_html.keyboardEvent) ev_unit
val onchange : ('a, Dom_html.event) ev
val onchange_select : ('a, Dom_html.event) ev
val ontoggle : ('a, Dom_html.toggleEvent) ev
end

module Attr : sig
Expand Down
12 changes: 12 additions & 0 deletions src/lib/eliom_content_.client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,14 @@ module Html = struct
(fun () -> failwith (Printf.sprintf "Non element node (%s)" name))
id

let get_unique_elt_details name elt : Dom_html.detailsElement Js.t =
Js.Opt.case
(Js.Opt.bind
(Dom_html.CoerceTo.element (get_unique_node name elt))
Dom_html.CoerceTo.details)
(fun () -> failwith (Printf.sprintf "Non element node (%s)" name))
id

let scrollIntoView ?(bottom = false) elt =
let elt = get_unique_elt "Css.background" elt in
elt ## (scrollIntoView (Js.bool (not bottom)))
Expand Down Expand Up @@ -612,6 +620,10 @@ module Html = struct
let onchange_select elt f =
let elt = get_unique_elt_select "Ev.onchange_select" elt in
elt##.onchange := bool_cb f

let ontoggle elt f =
let elt = get_unique_elt_details "Ev.ontoggle" elt in
elt##.ontoggle := bool_cb f
end

module Attr = struct
Expand Down
1 change: 1 addition & 0 deletions src/lib/eliom_content_core.client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ module Html = struct
let a_onsubmit s = A.Unsafe.string_attrib "onsubmit" s
let a_onsuspend s = A.Unsafe.string_attrib "onsuspend" s
let a_ontimeupdate s = A.Unsafe.string_attrib "ontimeupdate" s
let a_ontoggle s = A.Unsafe.string_attrib "ontoggle" s
let a_onundo s = A.Unsafe.string_attrib "onundo" s
let a_onunload s = A.Unsafe.string_attrib "onunload" s
let a_onvolumechange s = A.Unsafe.string_attrib "onvolumechange" s
Expand Down
1 change: 1 addition & 0 deletions src/lib/eliom_content_core.client.mli
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ module Html : sig
val a_onsubmit : string -> [> `OnSubmit] A.attrib
val a_onsuspend : string -> [> `OnSuspend] A.attrib
val a_ontimeupdate : string -> [> `OnTimeUpdate] A.attrib
val a_ontoggle : string -> [> `OnToggle] A.attrib
val a_onundo : string -> [> `OnUndo] A.attrib
val a_onunload : string -> [> `OnUnload] A.attrib
val a_onvolumechange : string -> [> `OnVolumeChange] A.attrib
Expand Down
1 change: 1 addition & 0 deletions src/lib/eliom_content_core.server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ module Html = struct
let a_onsubmit s = A.Unsafe.string_attrib "onsubmit" s
let a_onsuspend s = A.Unsafe.string_attrib "onsuspend" s
let a_ontimeupdate s = A.Unsafe.string_attrib "ontimeupdate" s
let a_ontoggle s = A.Unsafe.string_attrib "ontoggle" s
let a_onundo s = A.Unsafe.string_attrib "onundo" s
let a_onunload s = A.Unsafe.string_attrib "onunload" s
let a_onvolumechange s = A.Unsafe.string_attrib "onvolumechange" s
Expand Down
1 change: 1 addition & 0 deletions src/lib/eliom_content_core.server.mli
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ module Html : sig
val a_onsubmit : string -> [> `OnSubmit] A.attrib
val a_onsuspend : string -> [> `OnSuspend] A.attrib
val a_ontimeupdate : string -> [> `OnTimeUpdate] A.attrib
val a_ontoggle : string -> [> `OnToggle] A.attrib
val a_onundo : string -> [> `OnUndo] A.attrib
val a_onunload : string -> [> `OnUnload] A.attrib
val a_onvolumechange : string -> [> `OnVolumeChange] A.attrib
Expand Down

0 comments on commit bcb952e

Please sign in to comment.