Skip to content

Commit 3a7c42e

Browse files
committed
feat(js_utils): Add HTMLElement.title support
1 parent ffb8abc commit 3a7c42e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/utils/js_utils.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,18 @@ module Manip = struct
455455
elt##.oninput := (bool_cb f)
456456
end
457457

458+
module HTMLElement = struct
459+
let title elt =
460+
let elt = get_elt "HTMLElement.title" elt in
461+
Js.to_string (elt##.title)
462+
end
463+
464+
module SetHTMLElement = struct
465+
let title elt v =
466+
let elt = get_elt "HTMLElement.title" elt in
467+
elt##.title := Js.string v
468+
end
469+
458470
module Attr = struct
459471
let clientWidth elt =
460472
let elt = get_elt "Attr.clientWidth" elt in

src/utils/js_utils.mli

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ module Manip : sig
118118
val oninput: ('a,Dom_html.event) ev
119119
end
120120

121+
(** Read the properties of DOM elements. *)
122+
module HTMLElement : sig
123+
val title: 'a elt -> string
124+
end
125+
126+
(** Modify the properties of DOM elements. *)
127+
module SetHTMLElement : sig
128+
val title: 'a elt -> string -> unit
129+
end
130+
121131
module Attr : sig
122132
val clientWidth: 'a elt -> int
123133
val clientHeight: 'a elt -> int

0 commit comments

Comments
 (0)