From 48365f48b5901cbb9f8fa0b7d47eb120fb03985e Mon Sep 17 00:00:00 2001 From: Sylvain Boilard Date: Thu, 31 Oct 2024 17:23:55 +0100 Subject: [PATCH] Add support for the `popover` API and for the `name` attribute on `
` 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.md | 4 ++++ lib/html_f.ml | 14 ++++++++++++++ lib/html_sigs.mli | 8 ++++++++ lib/html_types.mli | 13 ++++++++++++- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 74ecef559..90ea60f3f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,10 @@ * Add support for the clip-path presentation attribute (#333 by Martin @MBodin Bodin) +* Add support for the `popover` API and for the `name` attribute on + `
` elements + (#341 by @SylvainBoilard) + # 4.6.0 * Update for OCaml 5.0 and drop support for OCaml 4.2.0 diff --git a/lib/html_f.ml b/lib/html_f.ml index 4e1484f99..308f31594 100644 --- a/lib/html_f.ml +++ b/lib/html_f.ml @@ -112,6 +112,7 @@ struct let a_onabort = Xml.event_handler_attrib "onabort" let a_onafterprint = Xml.event_handler_attrib "onafterprint" let a_onbeforeprint = Xml.event_handler_attrib "onbeforeprint" + let a_onbeforetoggle = Xml.event_handler_attrib "onbeforetoggle" let a_onbeforeunload = Xml.event_handler_attrib "onbeforeunload" let a_onblur = Xml.event_handler_attrib "onblur" let a_oncanplay = Xml.event_handler_attrib "oncanplay" @@ -151,6 +152,7 @@ struct let a_onsubmit = Xml.event_handler_attrib "onsubmit" let a_onsuspend = Xml.event_handler_attrib "onsuspend" let a_ontimeupdate = Xml.event_handler_attrib "ontimeupdate" + let a_ontoggle = Xml.event_handler_attrib "ontoggle" let a_onundo = Xml.event_handler_attrib "onundo" let a_onunload = Xml.event_handler_attrib "onunload" let a_onvolumechange = Xml.event_handler_attrib "onvolumechange" @@ -374,6 +376,14 @@ struct let a_placeholder = string_attrib "placeholder" + let a_popover x = + user_attrib C.string_of_big_variant "popover" x + + let a_popovertarget = string_attrib "popovertarget" + + let a_popovertargetaction x = + user_attrib C.string_of_big_variant "popovertargetaction" x + let a_poster = uri_attrib "poster" let a_preload x = @@ -1002,6 +1012,7 @@ struct | `Yes -> "yes" | `No -> "no" | `Auto -> "auto" + | `Manual -> "manual" | `Circle -> "circle" | `Poly -> "poly" | `Alternate -> "alternate" @@ -1039,6 +1050,9 @@ struct | `Url -> "url" | `Text -> "text" | `Decimal -> "decimal" + | `Hide -> "hide" + | `Show -> "show" + | `Toggle -> "toggle" | `Other s -> s let string_of_input_type = function diff --git a/lib/html_sigs.mli b/lib/html_sigs.mli index 1cf169c8f..d3121d13c 100644 --- a/lib/html_sigs.mli +++ b/lib/html_sigs.mli @@ -175,6 +175,7 @@ module type T = sig val a_onabort : Xml.event_handler -> [> | `OnAbort] attrib val a_onafterprint : Xml.event_handler -> [> | `OnAfterPrint] attrib val a_onbeforeprint : Xml.event_handler -> [> | `OnBeforePrint] attrib + val a_onbeforetoggle : Xml.event_handler -> [> | `OnBeforeToggle] attrib val a_onbeforeunload : Xml.event_handler -> [> | `OnBeforeUnload] attrib val a_onblur : Xml.event_handler -> [> | `OnBlur] attrib val a_oncanplay : Xml.event_handler -> [> | `OnCanPlay] attrib @@ -215,6 +216,7 @@ module type T = sig val a_onsubmit : Xml.event_handler -> [> | `OnSubmit] attrib val a_onsuspend : Xml.event_handler -> [> | `OnSuspend] attrib val a_ontimeupdate : Xml.event_handler -> [> | `OnTimeUpdate] attrib + val a_ontoggle : Xml.event_handler -> [> | `OnToggle] attrib val a_onundo : Xml.event_handler -> [> | `OnUndo] attrib val a_onunload : Xml.event_handler -> [> | `OnUnload] attrib val a_onvolumechange : Xml.event_handler -> [> | `OnVolumeChange] attrib @@ -343,6 +345,12 @@ module type T = sig val a_placeholder : text wrap -> [> | `Placeholder] attrib + val a_popover : [< | `Auto | `Manual] wrap -> [> | `Popover] attrib + + val a_popovertarget : text wrap -> [> | `Popovertarget] attrib + + val a_popovertargetaction : [< | `Hide | `Show | `Toggle] wrap -> [> | `Popovertargetaction] attrib + val a_poster : Xml.uri wrap -> [> | `Poster] attrib val a_preload : [< | `None | `Metadata | `Audio] wrap -> [> | `Preload] attrib diff --git a/lib/html_types.mli b/lib/html_types.mli index 7ccd3d3cc..02c6386c9 100644 --- a/lib/html_types.mli +++ b/lib/html_types.mli @@ -297,6 +297,7 @@ type core = | `Hidden | `Id | i18n + | `Popover | `Spellcheck | `Style_Attr | `Tabindex @@ -312,6 +313,7 @@ type core = type events = [ | `OnAbort + | `OnBeforeToggle | `OnBlur | `OnCanPlay | `OnCanPlayThrough @@ -357,6 +359,7 @@ type events = | `OnSubmit | `OnSuspend | `OnTimeUpdate + | `OnToggle | `OnTouchStart | `OnTouchEnd | `OnTouchMove @@ -2090,6 +2093,8 @@ type input_attrib = | `Name | `Pattern | `Placeholder + | `Popovertarget + | `Popovertargetaction | `ReadOnly | `Required | `Size @@ -2144,6 +2149,8 @@ type button_attrib = | `Formnovalidate | `Formtarget | `Name + | `Popovertarget + | `Popovertargetaction | `Text_Value | `Button_Type ] @@ -2233,7 +2240,7 @@ type details_content = [ | flow5 ] type details_content_fun = [ | flow5 ] -type details_attrib = [ | common | `Open ] +type details_attrib = [ | common | `Open | `Name ] (* NAME: summary, KIND: star, TYPE: [= common ],[= phrasing ], [=`Summary], ARG: [= phrasing ], ATTRIB: OUT: [=`Summary] *) type summary = [ | `Summary ] @@ -2401,6 +2408,7 @@ type big_variant = | `One | `Zero | `Auto + | `Manual | `No | `Yes | `Defer @@ -2418,6 +2426,9 @@ type big_variant = | `Text | `Decimal | `Search + | `Hide + | `Show + | `Toggle ] type sandbox_token =