diff options
Diffstat (limited to 'src/Lib/Dom/Element.ml')
-rw-r--r-- | src/Lib/Dom/Element.ml | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/Lib/Dom/Element.ml b/src/Lib/Dom/Element.ml index a72b783..391a95c 100644 --- a/src/Lib/Dom/Element.ml +++ b/src/Lib/Dom/Element.ml @@ -2,43 +2,36 @@ external set_value : Dom.element -> string -> unit = "value" [@@bs.set] external value : Dom.element -> string = "value" [@@bs.get] -external setTextContent : Dom.element -> string -> unit = "textContent" - [@@bs.set] - -external setStyle : Dom.element -> string -> unit = "style" [@@bs.set] - -external setClassName : Dom.element -> string -> unit = "className" [@@bs.set] - -external setAttribute : Dom.element -> string -> string -> unit = "setAttribute" +external set_attribute : Dom.element -> string -> string -> unit = "setAttribute" [@@bs.send] -external setAttributeNS : Dom.element -> string -> string -> string -> unit - = "setAttributeNS" +external add_event_listener : Dom.element -> string -> (Dom.event -> unit) -> unit + = "addEventListener" [@@bs.send] -external addEventListener : Dom.element -> string -> (Dom.event -> unit) -> unit - = "addEventListener" +external remove_event_listener : Dom.element -> string -> (Dom.event -> unit) -> unit + = "removeEventListener" [@@bs.send] -external appendChild : Dom.element -> Dom.element -> unit = "appendChild" +external append_child : Dom.element -> Dom.element -> unit = "appendChild" [@@bs.send] -external firstChild : Dom.element -> Dom.element Js.Nullable.t = "firstChild" +external first_child : Dom.element -> Dom.element Js.Nullable.t = "firstChild" [@@bs.get] -external removeChild : Dom.element -> Dom.element -> unit = "removeChild" +external remove_child : Dom.element -> Dom.element -> unit = "removeChild" [@@bs.send] -let removeFirstChild element = - match Js.toOption (firstChild element) with +let remove_first_child element = + match Js.toOption (first_child element) with | Some child -> - let () = removeChild element child in + let () = remove_child element child in true | _ -> false let rec remove_children element = - if removeFirstChild element then remove_children element else () + if remove_first_child element then remove_children element else () let mount_on base element = let () = remove_children base in - appendChild base element + append_child base element |