blob: e370cf538a28c51303099358ab87752b728a3260 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
external set_value : Dom.element -> string -> unit = "value"
[@@bs.set]
external value : Dom.element -> string = "value"
[@@bs.get]
external set_attribute : Dom.element -> string -> string -> unit = "setAttribute"
[@@bs.send]
external set_class_name : Dom.element -> string -> unit = "className"
[@@bs.set]
external add_event_listener : Dom.element -> string -> (Dom.event -> unit) -> unit
= "addEventListener"
[@@bs.send]
external remove_event_listener : Dom.element -> string -> (Dom.event -> unit) -> unit
= "removeEventListener"
[@@bs.send]
external append_child : Dom.element -> Dom.element -> unit = "appendChild"
[@@bs.send]
external first_child : Dom.element -> Dom.element Js.Nullable.t = "firstChild"
[@@bs.get]
external remove_child : Dom.element -> Dom.element -> unit = "removeChild"
[@@bs.send]
external click : Dom.element -> unit = "click"
[@@bs.send]
let remove_first_child element =
match Js.toOption (first_child element) with
| Some child ->
let () = remove_child element child in
true
| _ -> false
let rec remove_children element =
if remove_first_child element then remove_children element else ()
let mount_on base element =
let () = remove_children base in
append_child base element
external files : Dom.element -> string Js.Array.t = "files"
[@@bs.get]
|