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
|
let concat xs ys =
let partition_class =
Js.Array.reduce
(fun (class_acc, rest_acc) z ->
match z with
| H.TextAttr ("class", c) -> (class_acc ^ " " ^ c, rest_acc)
| _ -> (class_acc, Js.Array.concat [| z |] rest_acc)
)
("", [| |])
in
let (xs_class, xs_rest) = partition_class xs in
let (ys_class, ys_rest) = partition_class ys in
let rest = Js.Array.concat xs_rest ys_rest in
if xs_class == "" && ys_class == "" then
rest
else
Js.Array.concat [| H.TextAttr ("class", xs_class ^ " " ^ ys_class) |] rest
(* Attribute creation *)
let id v = H.TextAttr ("id", v)
let class_ v = H.TextAttr ("class", v)
let viewBox v = H.TextAttr ("viewBox", v)
let d v = H.TextAttr ("d", v)
let type_ v = H.TextAttr ("type", v)
let min_ v = H.TextAttr ("min", v)
let value v = H.TextAttr ("value", v)
let for_ v = H.TextAttr ("for", v)
let style v = H.TextAttr ("style", v)
let href v = H.TextAttr ("href", v)
let autocomplete v = H.TextAttr ("autocomplete", v)
let download v = H.TextAttr ("download", v)
|