Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[draft] Implement the popover API. #1734

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Runtime: reimplement the runtime of weak and ephemeron (#1707)
* Lib: Modify Typed_array API for compatibility with WebAssembly
* Lib: add details element and toggle event (#1728)
* Lib: implement popover API (#1734)
* Toplevel: no longer set globals for toplevel initialization
* Runtime: precompute constants used in `caml_lxm_next` (#1730)

Expand Down
30 changes: 28 additions & 2 deletions lib/js_of_ocaml/dom_html.ml
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ and eventTarget = object ('self)

method onpointerup : ('self t, pointerEvent t) event_listener writeonly_prop

method onbeforetoggle : ('self t, toggleEvent t) event_listener writeonly_prop

method ontoggle : ('self t, toggleEvent t) event_listener writeonly_prop

Comment on lines +560 to +563
Copy link
Contributor Author

@SylvainBoilard SylvainBoilard Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are similar methods related to event handlers in this file that have the prop type instead of writeonly_prop. In fact, the ontoggle method initially used the former type. Is this new version correct?

method dispatchEvent : event t -> bool t meth
end

Expand Down Expand Up @@ -735,6 +739,8 @@ and element = object

method scrollHeight : int prop

method popover : js_string t opt prop

method getClientRects : clientRectList t meth

method getBoundingClientRect : clientRect t meth
Expand All @@ -747,6 +753,18 @@ and element = object

method blur : unit meth

method hidePopover : unit meth

method showPopover : unit meth

method showPopover_options : _ -> unit meth

method togglePopover : bool t meth

method togglePopover_force : bool t -> bool t meth

method togglePopover_options : _ -> bool t meth

Comment on lines +758 to +767
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the specs, these methods accept a dictionary as a parameter for passing options. How would that be reflected in Js_of_ocaml?

inherit eventTarget
end

Expand Down Expand Up @@ -967,6 +985,8 @@ module Event = struct

let waiting = Dom.Event.make "waiting"

let beforetoggle = Dom.Event.make "beforetoggle"

let toggle = Dom.Event.make "toggle"

let make = Dom.Event.make
Expand Down Expand Up @@ -1197,6 +1217,10 @@ class type inputElement = object ('self)

method selectionEnd : int prop

method popovertarget : element t opt prop

method popovertargetaction : js_string t prop

method onselect : ('self t, event t) event_listener prop

method onchange : ('self t, event t) event_listener prop
Expand Down Expand Up @@ -1272,6 +1296,10 @@ class type buttonElement = object
method _type : js_string t readonly_prop

method value : js_string t prop

method popovertarget : element t opt prop

method popovertargetaction : js_string t prop
end

class type labelElement = object
Expand Down Expand Up @@ -1388,8 +1416,6 @@ class type detailsElement = object ('self)
method open_ : bool t prop

method name : js_string t prop

method ontoggle : ('self t, toggleEvent t) event_listener prop
end

class type imageElement = object ('self)
Expand Down
30 changes: 28 additions & 2 deletions lib/js_of_ocaml/dom_html.mli
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ and eventTarget = object ('self)

method onpointerup : ('self t, pointerEvent t) event_listener writeonly_prop

method onbeforetoggle : ('self t, toggleEvent t) event_listener writeonly_prop

method ontoggle : ('self t, toggleEvent t) event_listener writeonly_prop

method dispatchEvent : event t -> bool t meth
end

Expand Down Expand Up @@ -748,6 +752,8 @@ and element = object

method scrollHeight : int prop

method popover : js_string t opt prop

method getClientRects : clientRectList t meth

method getBoundingClientRect : clientRect t meth
Expand All @@ -760,6 +766,18 @@ and element = object

method blur : unit meth

method hidePopover : unit meth

method showPopover : unit meth

method showPopover_options : _ -> unit meth

method togglePopover : bool t meth

method togglePopover_force : bool t -> bool t meth

method togglePopover_options : _ -> bool t meth

inherit eventTarget
end

Expand Down Expand Up @@ -1007,6 +1025,10 @@ class type inputElement = object ('self)

method selectionEnd : int prop

method popovertarget : element t opt prop

method popovertargetaction : js_string t prop

method onselect : ('self t, event t) event_listener prop

method onchange : ('self t, event t) event_listener prop
Expand Down Expand Up @@ -1088,6 +1110,10 @@ class type buttonElement = object

(* Cannot be changed under IE *)
method value : js_string t prop

method popovertarget : element t opt prop

method popovertargetaction : js_string t prop
end

class type labelElement = object
Expand Down Expand Up @@ -1204,8 +1230,6 @@ class type detailsElement = object ('self)
method open_ : bool t prop

method name : js_string t prop

method ontoggle : ('self t, toggleEvent t) event_listener prop
end

class type imageElement = object ('self)
Expand Down Expand Up @@ -2521,6 +2545,8 @@ module Event : sig

val waiting : mediaEvent t typ

val beforetoggle : toggleEvent t typ

val toggle : toggleEvent t typ

val make : string -> 'a typ
Expand Down
Loading