From b6ddc9b788312ebd43fde699fd672f9dab7c72dd Mon Sep 17 00:00:00 2001 From: Sylvain Boilard Date: Thu, 31 Oct 2024 17:24:00 +0100 Subject: [PATCH] Add support for the `toggle` and `beforetoggle` events of the `popover` API. This also adds support for the `toggle` event for `details` elements. See: - https://html.spec.whatwg.org/multipage/popover.html ; - https://html.spec.whatwg.org/multipage/indices.html#event-toggle ; - https://html.spec.whatwg.org/multipage/interactive-elements.html#the-details-element ; - https://developer.mozilla.org/en-US/docs/Web/API/Popover_API ; - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details#events ; - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details#attributes . --- CHANGES | 4 ++++ src/lib/eliom_content.client.mli | 2 ++ src/lib/eliom_content_.client.ml | 8 ++++++++ src/lib/eliom_content_core.client.ml | 2 ++ src/lib/eliom_content_core.client.mli | 2 ++ src/lib/eliom_content_core.server.ml | 2 ++ src/lib/eliom_content_core.server.mli | 2 ++ 7 files changed, 22 insertions(+) diff --git a/CHANGES b/CHANGES index b32a1f8815..bd3c3e39bf 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +===== dev ===== +* Add support for the `toggle` and `beforetoggle` events of the `popover` API +** Also adds support for the `toggle` event for `details` elements + ===== 11.1 ===== * Compatibility with WASM diff --git a/src/lib/eliom_content.client.mli b/src/lib/eliom_content.client.mli index 51c793da5a..b7f022be2a 100644 --- a/src/lib/eliom_content.client.mli +++ b/src/lib/eliom_content.client.mli @@ -666,6 +666,8 @@ 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 onbeforetoggle : ('a, Dom_html.toggleEvent) ev + val ontoggle : ('a, Dom_html.toggleEvent) ev end module Attr : sig diff --git a/src/lib/eliom_content_.client.ml b/src/lib/eliom_content_.client.ml index 0639265fd2..e0f2ea2cea 100644 --- a/src/lib/eliom_content_.client.ml +++ b/src/lib/eliom_content_.client.ml @@ -612,6 +612,14 @@ 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 onbeforetoggle elt f = + let elt = get_unique_elt "Ev.onbeforetoggle" elt in + elt##.onbeforetoggle := bool_cb f + + let ontoggle elt f = + let elt = get_unique_elt "Ev.ontoggle" elt in + elt##.ontoggle := bool_cb f end module Attr = struct diff --git a/src/lib/eliom_content_core.client.ml b/src/lib/eliom_content_core.client.ml index fcacb910c8..e73b523e2d 100644 --- a/src/lib/eliom_content_core.client.ml +++ b/src/lib/eliom_content_core.client.ml @@ -353,6 +353,7 @@ module Html = struct let a_onabort s = A.Unsafe.string_attrib "onabort" s let a_onafterprint s = A.Unsafe.string_attrib "onafterprint" s let a_onbeforeprint s = A.Unsafe.string_attrib "onbeforeprint" s + let a_onbeforetoggle s = A.Unsafe.string_attrib "onbeforetoggle" s let a_onbeforeunload s = A.Unsafe.string_attrib "onbeforeunload" s let a_onblur s = A.Unsafe.string_attrib "onblur" s let a_oncanplay s = A.Unsafe.string_attrib "oncanplay" s @@ -393,6 +394,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 diff --git a/src/lib/eliom_content_core.client.mli b/src/lib/eliom_content_core.client.mli index c8bd795a28..1e590a3f4d 100644 --- a/src/lib/eliom_content_core.client.mli +++ b/src/lib/eliom_content_core.client.mli @@ -348,6 +348,7 @@ module Html : sig val a_onabort : string -> [> `OnAbort] A.attrib val a_onafterprint : string -> [> `OnAfterPrint] A.attrib val a_onbeforeprint : string -> [> `OnBeforePrint] A.attrib + val a_onbeforetoggle : string -> [> `OnBeforeToggle] A.attrib val a_onbeforeunload : string -> [> `OnBeforeUnload] A.attrib val a_onblur : string -> [> `OnBlur] A.attrib val a_oncanplay : string -> [> `OnCanPlay] A.attrib @@ -388,6 +389,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 diff --git a/src/lib/eliom_content_core.server.ml b/src/lib/eliom_content_core.server.ml index 639f00139d..fd69948546 100644 --- a/src/lib/eliom_content_core.server.ml +++ b/src/lib/eliom_content_core.server.ml @@ -371,6 +371,7 @@ module Html = struct let a_onabort s = A.Unsafe.string_attrib "onabort" s let a_onafterprint s = A.Unsafe.string_attrib "onafterprint" s let a_onbeforeprint s = A.Unsafe.string_attrib "onbeforeprint" s + let a_onbeforetoggle s = A.Unsafe.string_attrib "onbeforetoggle" s let a_onbeforeunload s = A.Unsafe.string_attrib "onbeforeunload" s let a_onblur s = A.Unsafe.string_attrib "onblur" s let a_oncanplay s = A.Unsafe.string_attrib "oncanplay" s @@ -411,6 +412,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 diff --git a/src/lib/eliom_content_core.server.mli b/src/lib/eliom_content_core.server.mli index 1d6be3aec0..c4fd75c4d1 100644 --- a/src/lib/eliom_content_core.server.mli +++ b/src/lib/eliom_content_core.server.mli @@ -216,6 +216,7 @@ module Html : sig val a_onabort : string -> [> `OnAbort] A.attrib val a_onafterprint : string -> [> `OnAfterPrint] A.attrib val a_onbeforeprint : string -> [> `OnBeforePrint] A.attrib + val a_onbeforetoggle : string -> [> `OnBeforeToggle] A.attrib val a_onbeforeunload : string -> [> `OnBeforeUnload] A.attrib val a_onblur : string -> [> `OnBlur] A.attrib val a_oncanplay : string -> [> `OnCanPlay] A.attrib @@ -256,6 +257,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