package eliom

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file eliom_content_.ml

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
# 1 "src/lib/eliom_content_.client.ml"
(* Ocsigen
 * http://www.ocsigen.org
 * Copyright (C) 2012 Vincent Balat, Benedikt Becker
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, with linking exception;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *)

open Js_of_ocaml
open Eliom_lib
open Eliom_content_core
module Xml = Xml

module MakeManip
    (Kind : sig
       type +'a elt

       val toelt : 'a elt -> Xml.elt
     end)
    (To_dom : sig
       val of_element : 'a Kind.elt -> Dom_html.element Js.t
     end)
    (Of_dom : sig
       val of_element : Dom_html.element Js.t -> 'a Kind.elt
     end)
    (Id : sig
       type 'a id

       val get_element' : 'a id -> Dom.node Js.t
     end)
    (Ns : sig
       val content_ns : Eliom_client_core.content_ns
     end) =
struct
  let get_node elt = (To_dom.of_element elt :> Dom.node Js.t)

  let get_unique_node context (elt : 'a Kind.elt) : Dom.node Js.t =
    match Xml.get_node (Kind.toelt elt) with
    | Xml.DomNode node -> node
    | Xml.ReactNode _ -> get_node elt
    | Xml.ReactChildren _ -> get_node elt
    | Xml.TyXMLNode _ -> (
        let elt' = Kind.toelt elt in
        match Xml.get_node_id elt' with
        | Xml.NoId ->
            Lwt_log.raise_error_f ~section:Lwt_log.eliom
              ~inspect:
                (Eliom_client_core.rebuild_node' Ns.content_ns (Kind.toelt elt))
              "Cannot call %s on an element with functional semantics" context
        | _ -> get_node elt)

  let get_unique_elt name elt : Dom_html.element Js.t =
    Js.Opt.case
      (Dom_html.CoerceTo.element (get_unique_node name elt))
      (fun () ->
         Lwt_log.raise_error_f ~section:Lwt_log.eliom
           ~inspect:
             (Eliom_client_core.rebuild_node' Ns.content_ns (Kind.toelt elt))
           "Cannot call %s on a node which is not an element" name)
      id

  let raw_appendChild ?before node elt2 =
    match before with
    | None -> ignore node ## (appendChild (get_node elt2))
    | Some elt3 ->
        let node3 = get_unique_node "appendChild" elt3 in
        ignore node ## (insertBefore (get_node elt2) (Js.some node3))

  let raw_appendChildren ?before node elts =
    match before with
    | None ->
        List.iter
          (fun elt2 -> ignore node ## (appendChild (get_node elt2)))
          elts
    | Some elt3 ->
        let node3 = get_unique_node "appendChild" elt3 in
        List.iter
          (fun elt2 ->
             ignore node ## (insertBefore (get_node elt2) (Js.some node3)))
          elts

  let raw_removeChild node1 elt2 =
    let node2 = get_unique_node "removeChild" elt2 in
    ignore node1 ## (removeChild node2)

  let raw_replaceChild node1 elt2 elt3 =
    let node3 = get_unique_node "replaceChild" elt3 in
    ignore node1 ## (replaceChild (get_node elt2) node3)

  let raw_removeChildren node =
    let childrens = Dom.list_of_nodeList node##.childNodes in
    List.iter (fun c -> ignore node ## (removeChild c)) childrens

  let raw_replaceChildren node elts =
    raw_removeChildren node;
    List.iter (fun elt -> ignore node ## (appendChild (get_node elt))) elts

  let nth elt n =
    let node = get_unique_node "nth" elt in
    let res =
      Js.Opt.bind
        node ##. childNodes ## (item n)
        (fun node ->
           Js.Opt.map (Dom.CoerceTo.element node) (fun node ->
             Of_dom.of_element (Dom_html.element node)))
    in
    Js.Opt.to_option res

  let childLength elt =
    let node = get_unique_node "childLength" elt in
    node##.childNodes##.length

  let appendChild ?before elt1 elt2 =
    let node = get_unique_node "appendChild" elt1 in
    raw_appendChild ?before node elt2

  let appendChildren ?before elt1 elts =
    let node = get_unique_node "appendChildren" elt1 in
    raw_appendChildren ?before node elts

  let removeChild elt1 elt2 =
    let node1 = get_unique_node "removeChild" elt1 in
    raw_removeChild node1 elt2

  let removeSelf elt =
    let node = get_unique_node "removeSelf" elt in
    let res =
      Js.Opt.bind node##.parentNode (fun node ->
        Js.Opt.map (Dom.CoerceTo.element node) (fun node ->
          Of_dom.of_element (Dom_html.element node)))
    in
    Js.Opt.iter res (fun p -> removeChild p elt)

  let insertFirstChild p c =
    let before = nth p 0 in
    appendChild ?before p c

  let replaceChild elt1 elt2 elt3 =
    let node1 = get_unique_node "replaceChild" elt1 in
    raw_replaceChild node1 elt2 elt3

  let removeChildren elt =
    let node = get_unique_node "removeChildren" elt in
    raw_removeChildren node

  let replaceChildren elt elts =
    let node = get_unique_node "replaceChildren" elt in
    raw_replaceChildren node elts

  let childNodes elt =
    let node = get_unique_node "childNodes" elt in
    Dom.list_of_nodeList node##.childNodes

  let rec filterElements coerce nodes =
    match nodes with
    | [] -> []
    | node :: nodes ->
        let elts = filterElements coerce nodes in
        Js.Opt.case (coerce node) (fun () -> elts) (fun elt -> elt :: elts)

  let childElements elt =
    let node = get_unique_node "childElements" elt in
    filterElements Dom.CoerceTo.element (Dom.list_of_nodeList node##.childNodes)

  let children elt =
    let node = get_unique_node "children" elt in
    List.map Of_dom.of_element
      (filterElements Dom_html.CoerceTo.element
         (Dom.list_of_nodeList node##.childNodes))

  let parentNode elt =
    let node = get_unique_node "parentNode" elt in
    let res =
      Js.Opt.bind node##.parentNode (fun node ->
        Js.Opt.map (Dom.CoerceTo.element node) (fun node ->
          Of_dom.of_element (Dom_html.element node)))
    in
    Js.Opt.to_option res

  let nextSibling elt =
    let node = get_unique_node "nextSibling" elt in
    let res =
      Js.Opt.bind node##.nextSibling (fun node ->
        Js.Opt.map (Dom.CoerceTo.element node) (fun node ->
          Of_dom.of_element (Dom_html.element node)))
    in
    Js.Opt.to_option res

  let previousSibling elt =
    let node = get_unique_node "previousSibling" elt in
    let res =
      Js.Opt.bind node##.previousSibling (fun node ->
        Js.Opt.map (Dom.CoerceTo.element node) (fun node ->
          Of_dom.of_element (Dom_html.element node)))
    in
    Js.Opt.to_option res

  let insertBefore ~before elt =
    Eliom_lib.Option.iter
      (fun parent -> appendChild ~before parent elt)
      (parentNode before)

  let insertAfter ~after elt =
    Eliom_lib.Option.iter
      (fun parent ->
         let before = nextSibling after in
         appendChild ?before parent elt)
      (parentNode after)

  let replaceSelf elt1 elt2 =
    Eliom_lib.Option.iter
      (fun parent -> replaceChild parent elt2 elt1)
      (parentNode elt1)

  module RawNamed = struct
    let appendChild ?before id1 elt2 =
      let node = Id.get_element' id1 in
      raw_appendChild ?before node elt2

    let appendChildren ?before id1 elts =
      let node = Id.get_element' id1 in
      raw_appendChildren ?before node elts

    let removeChild id1 elt2 =
      let node1 = Id.get_element' id1 in
      raw_removeChild node1 elt2

    let replaceChild id1 elt2 elt3 =
      let node1 = Id.get_element' id1 in
      raw_replaceChild node1 elt2 elt3

    let removeChildren id =
      let node = Id.get_element' id in
      raw_removeChildren node

    let replaceChildren id elts =
      let node = Id.get_element' id in
      raw_replaceChildren node elts
  end

  module Class = struct
    let contain elt class_name =
      let elt = get_unique_elt "Class.contain" elt in
      let class_name = Js.string class_name in
      let class_list = elt##.classList in
      Js.to_bool class_list ## (contains class_name)

    let add_raw elt class_name =
      let class_name = Js.string class_name in
      let class_list = elt##.classList in
      if Js.to_bool class_list ## (contains class_name)
      then ()
      else class_list ## (add class_name)

    let add elt class_name =
      let elt = get_unique_elt "Class.add" elt in
      add_raw elt class_name

    let adds elt class_list =
      let elt = get_unique_elt "Class.adds" elt in
      List.iter (fun class_name -> add_raw elt class_name) class_list

    let remove_raw elt class_name =
      let class_name = Js.string class_name in
      let class_list = elt##.classList in
      if Js.to_bool class_list ## (contains class_name)
      then class_list ## (remove class_name)
      else ()

    let remove elt class_name =
      let elt = get_unique_elt "Class.remove" elt in
      remove_raw elt class_name

    let removes elt class_list =
      let elt = get_unique_elt "Class.removes" elt in
      List.iter (fun class_name -> remove_raw elt class_name) class_list

    let replace elt class_name_1 class_name_2 =
      let elt = get_unique_elt "Class.replace" elt in
      remove_raw elt class_name_1;
      add_raw elt class_name_2

    let clear elt =
      let elt = get_unique_elt "Class.clear" elt in
      let class_list = elt##.classList in
      let l = class_list##.length in
      for i = l - 1 downto 0 do
        (* /!\ use downto because the list is re-ordered after each add/remove *)
        Js.Optdef.iter
          class_list ## (item i)
          (fun cl -> class_list ## (remove cl))
      done

    let toggle elt cl1 = if contain elt cl1 then remove elt cl1 else add elt cl1

    let toggle2 elt cl1 cl2 =
      if contain elt cl1 then replace elt cl1 cl2 else replace elt cl2 cl1
  end
end

module Svg = struct
  module Ev' = Svg.Ev'
  module F = Svg.F
  module D = Svg.D
  module R = Svg.R

  module C = struct
    let node ?init:_ x = x
    let attr ?init:_ x = x
  end

  type +'a elt = 'a F.elt
  type +'a attrib = 'a F.attrib
  type uri = F.uri

  module Of_dom = Eliom_content_core.Svg.Of_dom

  module To_dom = struct
    open Eliom_client_core

    let of_element elt = rebuild_node_svg "of_element" elt
    let of_node elt = rebuild_node_svg "of_node" elt
    let of_pcdata elt = rebuild_node_svg "of_pcdata" elt
  end

  module Id = struct
    include Svg.Id

    let get_element' id =
      let id = string_of_id id in
      let node = Eliom_client_core.getElementById id in
      Js.Opt.case
        (Dom_html.CoerceTo.element node)
        (fun () -> failwith (Printf.sprintf "Non element node (%s)" id))
        (fun x -> x)

    let get_element id =
      try Some (Of_dom.of_element (get_element' id)) with Failure _ -> None
  end

  module Manip = struct
    include
      MakeManip (F) (To_dom) (Of_dom)
        (struct
          type 'a id = 'a Id.id

          let get_element' id = (Id.get_element' id :> Dom.node Js.t)
        end)
        (struct
          let content_ns = `SVG
        end)

    module Named = RawNamed
  end
end

module Html = struct
  module Ev' = Html.Ev'

  module F = struct
    include Html.F

    module Arg = struct
      include Html.F
      module Svg = Eliom_content_core.Svg.F

      let uri_of_fun = Eliom_content_core.Xml.uri_of_fun

      let attrib_of_service s info =
        Eliom_content_core.(
          Html.F.to_attrib
            (Xml.internal_event_handler_attrib s
               (Xml.internal_event_handler_of_service info)))

      let to_elt = toelt
    end

    include Eliom_form.Make_links (Arg)
    module Form = Eliom_form.Make (Arg)
  end

  module R = struct
    include Html.R
  end

  module D = struct
    include Html.D

    module Arg = struct
      include Html.D
      module Svg = Eliom_content_core.Svg.D

      let uri_of_fun = Eliom_content_core.Xml.uri_of_fun

      let attrib_of_service s info =
        Eliom_content_core.(
          Html.D.to_attrib
            (Xml.internal_event_handler_attrib s
               (Xml.internal_event_handler_of_service info)))

      let to_elt = toelt
    end

    include Eliom_form.Make_links (Arg)
    module Form = Eliom_form.Make (Arg)
  end

  module C = struct
    let node ?init:_ x = x
    let attr ?init:_ x = x
  end

  type +'a elt = 'a F.elt
  type +'a attrib = 'a F.attrib
  type uri = F.uri
  type 'a form_param = 'a Eliom_form.param

  module Custom_data = Eliom_content_core.Html.Custom_data
  module Of_dom = Eliom_content_core.Html.Of_dom

  module To_dom = Js_of_ocaml_tyxml.Tyxml_cast.MakeTo (struct
      type 'a elt = 'a F.elt

      let elt x = Js.Unsafe.coerce (Eliom_client_core.rebuild_node "n/a" x)
    end)

  module Id = struct
    include Html.Id

    let get_element' id =
      let id = string_of_id id in
      let node = Eliom_client_core.getElementById id in
      Js.Opt.case
        (Dom_html.CoerceTo.element node)
        (fun () -> failwith (Printf.sprintf "Non element node (%s)" id))
        (fun x -> x)

    let get_element id =
      try Some (Of_dom.of_element (get_element' id)) with Failure _ -> None
  end

  module Manip = struct
    include
      MakeManip (F) (To_dom) (Of_dom)
        (struct
          type 'a id = 'a Id.id

          let get_element' id = (Id.get_element' id :> Dom.node Js.t)
        end)
        (struct
          let content_ns = `HTML5
        end)

    let raw_addEventListener ?(capture = false) node event handler =
      Dom_html.addEventListener node event
        (Dom_html.full_handler (fun n e ->
           Js.bool (handler (Html.F.tot (Xml.make_dom (n :> Dom.node Js.t))) e)))
        (Js.bool capture)

    let addEventListener ?capture target event handler =
      let node = get_unique_elt "addEventListener" target in
      raw_addEventListener ?capture node event handler

    module Named = struct
      include RawNamed

      let addEventListener ?capture id event handler =
        let node = Id.get_element' id in
        raw_addEventListener ?capture node event handler
    end

    let appendToBody ?before elt2 =
      let body = Of_dom.of_body Dom_html.window##.document##.body in
      appendChild ?before body elt2

    let get_unique_elt_input name elt : Dom_html.inputElement Js.t =
      Js.Opt.case
        (Js.Opt.bind
           (Dom_html.CoerceTo.element (get_unique_node name elt))
           Dom_html.CoerceTo.input)
        (fun () -> failwith (Printf.sprintf "Non element node (%s)" name))
        id

    let get_unique_elt_select name elt : Dom_html.selectElement Js.t =
      Js.Opt.case
        (Js.Opt.bind
           (Dom_html.CoerceTo.element (get_unique_node name elt))
           Dom_html.CoerceTo.select)
        (fun () -> failwith (Printf.sprintf "Non element node (%s)" name))
        id

    let get_unique_elt_textarea name elt : Dom_html.textAreaElement Js.t =
      Js.Opt.case
        (Js.Opt.bind
           (Dom_html.CoerceTo.element (get_unique_node name elt))
           Dom_html.CoerceTo.textarea)
        (fun () -> failwith (Printf.sprintf "Non element node (%s)" name))
        id

    let get_unique_elt_img name elt : Dom_html.imageElement Js.t =
      Js.Opt.case
        (Js.Opt.bind
           (Dom_html.CoerceTo.element (get_unique_node name elt))
           Dom_html.CoerceTo.img)
        (fun () -> failwith (Printf.sprintf "Non element node (%s)" name))
        id

    let scrollIntoView ?(bottom = false) elt =
      let elt = get_unique_elt "Css.background" elt in
      elt ## (scrollIntoView (Js.bool (not bottom)))

    module Elt = struct
      let body () = Of_dom.of_body Dom_html.window##.document##.body
    end

    module Ev = struct
      type ('a, 'b) ev = 'a elt -> ('b Js.t -> bool) -> unit
      type ('a, 'b) ev_unit = 'a elt -> ('b Js.t -> unit) -> unit

      let bool_cb f = Dom_html.handler (fun e -> Js.bool (f e))

      let onkeyup elt f =
        let elt = get_unique_elt "Ev.onkeyup" elt in
        elt##.onkeyup := bool_cb f

      let onkeydown elt f =
        let elt = get_unique_elt "Ev.onkeydown" elt in
        elt##.onkeydown := bool_cb f

      let onmouseup elt f =
        let elt = get_unique_elt "Ev.onmouseup" elt in
        elt##.onmouseup := bool_cb f

      let onmousedown elt f =
        let elt = get_unique_elt "Ev.onmousedown" elt in
        elt##.onmousedown := bool_cb f

      let onmouseout elt f =
        let elt = get_unique_elt "Ev.onmouseout" elt in
        elt##.onmouseout := bool_cb f

      let onmouseover elt f =
        let elt = get_unique_elt "Ev.onmouseover" elt in
        elt##.onmouseover := bool_cb f

      let onclick elt f =
        let elt = get_unique_elt "Ev.onclick" elt in
        elt##.onclick := bool_cb f

      let ondblclick elt f =
        let elt = get_unique_elt "Ev.ondblclick" elt in
        elt##.ondblclick := bool_cb f

      let onload elt f =
        let elt = get_unique_elt_img "Ev.onload" elt in
        elt##.onload := bool_cb f

      let onerror elt f =
        let elt = get_unique_elt_img "Ev.onerror" elt in
        elt##.onerror := bool_cb f

      let onabort elt f =
        let elt = get_unique_elt_img "Ev.onabort" elt in
        elt##.onabort := bool_cb f

      let onfocus :> (_, Dom_html.event) ev =
       fun elt f ->
        let elt = get_unique_elt_input "Ev.onfocus" elt in
        elt##.onfocus := bool_cb f

      let onblur :> (_, Dom_html.event) ev =
       fun elt f ->
        let elt = get_unique_elt_input "Ev.onblur" elt in
        elt##.onblur := bool_cb f

      let onfocus_textarea :> (_, Dom_html.event) ev =
       fun elt f ->
        let elt = get_unique_elt_textarea "Ev.onfocus" elt in
        elt##.onfocus := bool_cb f

      let onblur_textarea :> (_, Dom_html.event) ev =
       fun elt f ->
        let elt = get_unique_elt_textarea "Ev.onblur" elt in
        elt##.onblur := bool_cb f

      let onscroll elt f =
        let elt = get_unique_elt "Ev.onscroll" elt in
        elt##.onscroll := bool_cb f

      let onreturn elt f =
        let f ev =
          if Dom_html.Keyboard_code.(of_event ev = Enter) then f ev;
          true
        in
        onkeydown elt f

      let onchange elt f =
        let elt = get_unique_elt_input "Ev.onchange" elt in
        elt##.onchange := bool_cb f

      let onchange_select elt f =
        let elt = get_unique_elt_select "Ev.onchange_select" elt in
        elt##.onchange := bool_cb f
    end

    module Attr = struct
      let clientWidth elt =
        let elt = get_unique_elt "Attr.clientWidth" elt in
        elt##.clientWidth

      let clientHeight elt =
        let elt = get_unique_elt "Attr.clientHeight" elt in
        elt##.clientHeight

      let offsetWidth elt =
        let elt = get_unique_elt "Attr.offsetWidth" elt in
        elt##.offsetWidth

      let offsetHeight elt =
        let elt = get_unique_elt "Attr.offsetHeight" elt in
        elt##.offsetHeight

      let clientLeft elt =
        let elt = get_unique_elt "Attr.clientLeft" elt in
        elt##.clientLeft

      let clientTop elt =
        let elt = get_unique_elt "Attr.clientTop" elt in
        elt##.clientTop
    end

    module Css = struct
      let background elt =
        let elt = get_unique_elt "Css.background" elt in
        Js.to_bytestring elt##.style##.background

      let backgroundAttachment elt =
        let elt = get_unique_elt "Css.backgroundAttachment" elt in
        Js.to_bytestring elt##.style##.backgroundAttachment

      let backgroundColor elt =
        let elt = get_unique_elt "Css.backgroundColor" elt in
        Js.to_bytestring elt##.style##.backgroundColor

      let backgroundImage elt =
        let elt = get_unique_elt "Css.backgroundImage" elt in
        Js.to_bytestring elt##.style##.backgroundImage

      let backgroundPosition elt =
        let elt = get_unique_elt "Css.backgroundPosition" elt in
        Js.to_bytestring elt##.style##.backgroundPosition

      let backgroundRepeat elt =
        let elt = get_unique_elt "Css.backgroundRepeat" elt in
        Js.to_bytestring elt##.style##.backgroundRepeat

      let border elt =
        let elt = get_unique_elt "Css.border" elt in
        Js.to_bytestring elt##.style##.border

      let borderBottom elt =
        let elt = get_unique_elt "Css.borderBottom" elt in
        Js.to_bytestring elt##.style##.borderBottom

      let borderBottomColor elt =
        let elt = get_unique_elt "Css.borderBottomColor" elt in
        Js.to_bytestring elt##.style##.borderBottomColor

      let borderBottomStyle elt =
        let elt = get_unique_elt "Css.borderBottomStyle" elt in
        Js.to_bytestring elt##.style##.borderBottomStyle

      let borderBottomWidth elt =
        let elt = get_unique_elt "Css.borderBottomWidth" elt in
        Js.to_bytestring elt##.style##.borderBottomWidth

      let borderBottomWidthPx elt =
        let elt = get_unique_elt "Css.borderBottomWidthPx" elt in
        Js.parseInt elt##.style##.borderBottomWidth

      let borderCollapse elt =
        let elt = get_unique_elt "Css.borderCollapse" elt in
        Js.to_bytestring elt##.style##.borderCollapse

      let borderColor elt =
        let elt = get_unique_elt "Css.borderColor" elt in
        Js.to_bytestring elt##.style##.borderColor

      let borderLeft elt =
        let elt = get_unique_elt "Css.borderLeft" elt in
        Js.to_bytestring elt##.style##.borderLeft

      let borderLeftColor elt =
        let elt = get_unique_elt "Css.borderLeftColor" elt in
        Js.to_bytestring elt##.style##.borderLeftColor

      let borderLeftStyle elt =
        let elt = get_unique_elt "Css.borderLeftStyle" elt in
        Js.to_bytestring elt##.style##.borderLeftStyle

      let borderLeftWidth elt =
        let elt = get_unique_elt "Css.borderLeftWidth" elt in
        Js.to_bytestring elt##.style##.borderLeftWidth

      let borderLeftWidthPx elt =
        let elt = get_unique_elt "Css.borderLeftWidthPx" elt in
        Js.parseInt elt##.style##.borderLeftWidth

      let borderRight elt =
        let elt = get_unique_elt "Css.borderRight" elt in
        Js.to_bytestring elt##.style##.borderRight

      let borderRightColor elt =
        let elt = get_unique_elt "Css.borderRightColor" elt in
        Js.to_bytestring elt##.style##.borderRightColor

      let borderRightStyle elt =
        let elt = get_unique_elt "Css.borderRightStyle" elt in
        Js.to_bytestring elt##.style##.borderRightStyle

      let borderRightWidth elt =
        let elt = get_unique_elt "Css.borderRightWidth" elt in
        Js.to_bytestring elt##.style##.borderRightWidth

      let borderRightWidthPx elt =
        let elt = get_unique_elt "Css.borderRightWidthPx" elt in
        Js.parseInt elt##.style##.borderRightWidth

      let borderSpacing elt =
        let elt = get_unique_elt "Css.borderSpacing" elt in
        Js.to_bytestring elt##.style##.borderSpacing

      let borderStyle elt =
        let elt = get_unique_elt "Css.borderStyle" elt in
        Js.to_bytestring elt##.style##.borderStyle

      let borderTop elt =
        let elt = get_unique_elt "Css.borderTop" elt in
        Js.to_bytestring elt##.style##.borderTop

      let borderTopColor elt =
        let elt = get_unique_elt "Css.borderTopColor" elt in
        Js.to_bytestring elt##.style##.borderTopColor

      let borderTopStyle elt =
        let elt = get_unique_elt "Css.borderTopStyle" elt in
        Js.to_bytestring elt##.style##.borderTopStyle

      let borderTopWidth elt =
        let elt = get_unique_elt "Css.borderTopWidth" elt in
        Js.to_bytestring elt##.style##.borderTopWidth

      let borderTopWidthPx elt =
        let elt = get_unique_elt "Css.borderTopWidthPx" elt in
        Js.parseInt elt##.style##.borderTopWidth

      let borderWidth elt =
        let elt = get_unique_elt "Css.borderWidth" elt in
        Js.to_bytestring elt##.style##.borderWidth

      let borderWidthPx elt =
        let elt = get_unique_elt "Css.borderWidthPx" elt in
        Js.parseInt elt##.style##.borderWidth

      let bottom elt =
        let elt = get_unique_elt "Css.bottom" elt in
        Js.to_bytestring elt##.style##.bottom

      let captionSide elt =
        let elt = get_unique_elt "Css.captionSide" elt in
        Js.to_bytestring elt##.style##.captionSide

      let clear elt =
        let elt = get_unique_elt "Css.clear" elt in
        Js.to_bytestring elt##.style##.clear

      let clip elt =
        let elt = get_unique_elt "Css.clip" elt in
        Js.to_bytestring elt##.style##.clip

      let color elt =
        let elt = get_unique_elt "Css.color" elt in
        Js.to_bytestring elt##.style##.color

      let content elt =
        let elt = get_unique_elt "Css.content" elt in
        Js.to_bytestring elt##.style##.content

      let counterIncrement elt =
        let elt = get_unique_elt "Css.counterIncrement" elt in
        Js.to_bytestring elt##.style##.counterIncrement

      let counterReset elt =
        let elt = get_unique_elt "Css.counterReset" elt in
        Js.to_bytestring elt##.style##.counterReset

      let cssFloat elt =
        let elt = get_unique_elt "Css.cssFloat" elt in
        Js.to_bytestring elt##.style##.cssFloat

      let cssText elt =
        let elt = get_unique_elt "Css.cssText" elt in
        Js.to_bytestring elt##.style##.cssText

      let cursor elt =
        let elt = get_unique_elt "Css.cursor" elt in
        Js.to_bytestring elt##.style##.cursor

      let direction elt =
        let elt = get_unique_elt "Css.direction" elt in
        Js.to_bytestring elt##.style##.direction

      let display elt =
        let elt = get_unique_elt "Css.display" elt in
        Js.to_bytestring elt##.style##.display

      let emptyCells elt =
        let elt = get_unique_elt "Css.emptyCells" elt in
        Js.to_bytestring elt##.style##.emptyCells

      let font elt =
        let elt = get_unique_elt "Css.font" elt in
        Js.to_bytestring elt##.style##.font

      let fontFamily elt =
        let elt = get_unique_elt "Css.fontFamily" elt in
        Js.to_bytestring elt##.style##.fontFamily

      let fontSize elt =
        let elt = get_unique_elt "Css.fontSize" elt in
        Js.to_bytestring elt##.style##.fontSize

      let fontStyle elt =
        let elt = get_unique_elt "Css.fontStyle" elt in
        Js.to_bytestring elt##.style##.fontStyle

      let fontVariant elt =
        let elt = get_unique_elt "Css.fontVariant" elt in
        Js.to_bytestring elt##.style##.fontVariant

      let fontWeight elt =
        let elt = get_unique_elt "Css.fontWeight" elt in
        Js.to_bytestring elt##.style##.fontWeight

      let height elt =
        let elt = get_unique_elt "Css.height" elt in
        Js.to_bytestring elt##.style##.height

      let heightPx elt =
        let elt = get_unique_elt "Css.heightPx" elt in
        Js.parseInt elt##.style##.height

      let left elt =
        let elt = get_unique_elt "Css.left" elt in
        Js.to_bytestring elt##.style##.left

      let leftPx elt =
        let elt = get_unique_elt "Css.leftPx" elt in
        Js.parseInt elt##.style##.left

      let letterSpacing elt =
        let elt = get_unique_elt "Css.letterSpacing" elt in
        Js.to_bytestring elt##.style##.letterSpacing

      let lineHeight elt =
        let elt = get_unique_elt "Css.lineHeight" elt in
        Js.to_bytestring elt##.style##.lineHeight

      let listStyle elt =
        let elt = get_unique_elt "Css.listStyle" elt in
        Js.to_bytestring elt##.style##.listStyle

      let listStyleImage elt =
        let elt = get_unique_elt "Css.listStyleImage" elt in
        Js.to_bytestring elt##.style##.listStyleImage

      let listStylePosition elt =
        let elt = get_unique_elt "Css.listStylePosition" elt in
        Js.to_bytestring elt##.style##.listStylePosition

      let listStyleType elt =
        let elt = get_unique_elt "Css.listStyleType" elt in
        Js.to_bytestring elt##.style##.listStyleType

      let margin elt =
        let elt = get_unique_elt "Css.margin" elt in
        Js.to_bytestring elt##.style##.margin

      let marginBottom elt =
        let elt = get_unique_elt "Css.marginBottom" elt in
        Js.to_bytestring elt##.style##.marginBottom

      let marginBottomPx elt =
        let elt = get_unique_elt "Css.marginBottomPx" elt in
        Js.parseInt elt##.style##.marginBottom

      let marginLeft elt =
        let elt = get_unique_elt "Css.marginLeft" elt in
        Js.to_bytestring elt##.style##.marginLeft

      let marginLeftPx elt =
        let elt = get_unique_elt "Css.marginLeftPx" elt in
        Js.parseInt elt##.style##.marginLeft

      let marginRight elt =
        let elt = get_unique_elt "Css.marginRight" elt in
        Js.to_bytestring elt##.style##.marginRight

      let marginRightPx elt =
        let elt = get_unique_elt "Css.marginRightPx" elt in
        Js.parseInt elt##.style##.marginRight

      let marginTop elt =
        let elt = get_unique_elt "Css.marginTop" elt in
        Js.to_bytestring elt##.style##.marginTop

      let marginTopPx elt =
        let elt = get_unique_elt "Css.marginTopPx" elt in
        Js.parseInt elt##.style##.marginTop

      let maxHeight elt =
        let elt = get_unique_elt "Css.maxHeight" elt in
        Js.to_bytestring elt##.style##.maxHeight

      let maxHeightPx elt =
        let elt = get_unique_elt "Css.maxHeightPx" elt in
        Js.parseInt elt##.style##.maxHeight

      let maxWidth elt =
        let elt = get_unique_elt "Css.maxWidth" elt in
        Js.to_bytestring elt##.style##.maxWidth

      let maxWidthPx elt =
        let elt = get_unique_elt "Css.maxWidthPx" elt in
        Js.parseInt elt##.style##.maxWidth

      let minHeight elt =
        let elt = get_unique_elt "Css.minHeight" elt in
        Js.to_bytestring elt##.style##.minHeight

      let minHeightPx elt =
        let elt = get_unique_elt "Css.minHeightPx" elt in
        Js.parseInt elt##.style##.minHeight

      let minWidth elt =
        let elt = get_unique_elt "Css.minWidth" elt in
        Js.to_bytestring elt##.style##.minWidth

      let minWidthPx elt =
        let elt = get_unique_elt "Css.minWidthPx" elt in
        Js.parseInt elt##.style##.minWidth

      let opacity elt =
        let elt = get_unique_elt "Css.opacity" elt in
        Option.map Js.to_bytestring (Js.Optdef.to_option elt##.style##.opacity)

      let outline elt =
        let elt = get_unique_elt "Css.outline" elt in
        Js.to_bytestring elt##.style##.outline

      let outlineColor elt =
        let elt = get_unique_elt "Css.outlineColor" elt in
        Js.to_bytestring elt##.style##.outlineColor

      let outlineOffset elt =
        let elt = get_unique_elt "Css.outlineOffset" elt in
        Js.to_bytestring elt##.style##.outlineOffset

      let outlineStyle elt =
        let elt = get_unique_elt "Css.outlineStyle" elt in
        Js.to_bytestring elt##.style##.outlineStyle

      let outlineWidth elt =
        let elt = get_unique_elt "Css.outlineWidth" elt in
        Js.to_bytestring elt##.style##.outlineWidth

      let overflow elt =
        let elt = get_unique_elt "Css.overflow" elt in
        Js.to_bytestring elt##.style##.overflow

      let overflowX elt =
        let elt = get_unique_elt "Css.overflowX" elt in
        Js.to_bytestring elt##.style##.overflowX

      let overflowY elt =
        let elt = get_unique_elt "Css.overflowY" elt in
        Js.to_bytestring elt##.style##.overflowY

      let padding elt =
        let elt = get_unique_elt "Css.padding" elt in
        Js.to_bytestring elt##.style##.padding

      let paddingBottom elt =
        let elt = get_unique_elt "Css.paddingBottom" elt in
        Js.to_bytestring elt##.style##.paddingBottom

      let paddingBottomPx elt =
        let elt = get_unique_elt "Css.paddingBottomPx" elt in
        Js.parseInt elt##.style##.paddingBottom

      let paddingLeft elt =
        let elt = get_unique_elt "Css.paddingLeft" elt in
        Js.to_bytestring elt##.style##.paddingLeft

      let paddingLeftPx elt =
        let elt = get_unique_elt "Css.paddingLeftPx" elt in
        Js.parseInt elt##.style##.paddingLeft

      let paddingRight elt =
        let elt = get_unique_elt "Css.paddingRight" elt in
        Js.to_bytestring elt##.style##.paddingRight

      let paddingRightPx elt =
        let elt = get_unique_elt "Css.paddingRightPx" elt in
        Js.parseInt elt##.style##.paddingRight

      let paddingTop elt =
        let elt = get_unique_elt "Css.paddingTop" elt in
        Js.to_bytestring elt##.style##.paddingTop

      let paddingTopPx elt =
        let elt = get_unique_elt "Css.paddingTopPx" elt in
        Js.parseInt elt##.style##.paddingTop

      let pageBreakAfter elt =
        let elt = get_unique_elt "Css.pageBreakAfter" elt in
        Js.to_bytestring elt##.style##.pageBreakAfter

      let pageBreakBefore elt =
        let elt = get_unique_elt "Css.pageBreakBefore" elt in
        Js.to_bytestring elt##.style##.pageBreakBefore

      let position elt =
        let elt = get_unique_elt "Css.position" elt in
        Js.to_bytestring elt##.style##.position

      let right elt =
        let elt = get_unique_elt "Css.right" elt in
        Js.to_bytestring elt##.style##.right

      let rightPx elt =
        let elt = get_unique_elt "Css.rightPx" elt in
        Js.parseInt elt##.style##.right

      let tableLayout elt =
        let elt = get_unique_elt "Css.tableLayout" elt in
        Js.to_bytestring elt##.style##.tableLayout

      let textAlign elt =
        let elt = get_unique_elt "Css.textAlign" elt in
        Js.to_bytestring elt##.style##.textAlign

      let textDecoration elt =
        let elt = get_unique_elt "Css.textDecoration" elt in
        Js.to_bytestring elt##.style##.textDecoration

      let textIndent elt =
        let elt = get_unique_elt "Css.textIndent" elt in
        Js.to_bytestring elt##.style##.textIndent

      let textTransform elt =
        let elt = get_unique_elt "Css.textTransform" elt in
        Js.to_bytestring elt##.style##.textTransform

      let top elt =
        let elt = get_unique_elt "Css.top" elt in
        Js.to_bytestring elt##.style##.top

      let topPx elt =
        let elt = get_unique_elt "Css.topPx" elt in
        Js.parseInt elt##.style##.top

      let verticalAlign elt =
        let elt = get_unique_elt "Css.verticalAlign" elt in
        Js.to_bytestring elt##.style##.verticalAlign

      let visibility elt =
        let elt = get_unique_elt "Css.visibility" elt in
        Js.to_bytestring elt##.style##.visibility

      let whiteSpace elt =
        let elt = get_unique_elt "Css.whiteSpace" elt in
        Js.to_bytestring elt##.style##.whiteSpace

      let width elt =
        let elt = get_unique_elt "Css.width" elt in
        Js.to_bytestring elt##.style##.width

      let widthPx elt =
        let elt = get_unique_elt "Css.widthPx" elt in
        Js.parseInt elt##.style##.width

      let wordSpacing elt =
        let elt = get_unique_elt "Css.wordSpacing" elt in
        Js.to_bytestring elt##.style##.wordSpacing

      let zIndex elt =
        let elt = get_unique_elt "Css.zIndex" elt in
        Js.to_bytestring elt##.style##.zIndex
    end

    module SetCss = struct
      let background elt v =
        let elt = get_unique_elt "SetCss.background" elt in
        elt##.style##.background := Js.bytestring v

      let backgroundAttachment elt v =
        let elt = get_unique_elt "SetCss.backgroundAttachment" elt in
        elt##.style##.backgroundAttachment := Js.bytestring v

      let backgroundColor elt v =
        let elt = get_unique_elt "SetCss.backgroundColor" elt in
        elt##.style##.backgroundColor := Js.bytestring v

      let backgroundImage elt v =
        let elt = get_unique_elt "SetCss.backgroundImage" elt in
        elt##.style##.backgroundImage := Js.bytestring v

      let backgroundPosition elt v =
        let elt = get_unique_elt "SetCss.backgroundPosition" elt in
        elt##.style##.backgroundPosition := Js.bytestring v

      let backgroundRepeat elt v =
        let elt = get_unique_elt "SetCss.backgroundRepeat" elt in
        elt##.style##.backgroundRepeat := Js.bytestring v

      let border elt v =
        let elt = get_unique_elt "SetCss.border" elt in
        elt##.style##.border := Js.bytestring v

      let borderBottom elt v =
        let elt = get_unique_elt "SetCss.borderBottom" elt in
        elt##.style##.borderBottom := Js.bytestring v

      let borderBottomColor elt v =
        let elt = get_unique_elt "SetCss.borderBottomColor" elt in
        elt##.style##.borderBottomColor := Js.bytestring v

      let borderBottomStyle elt v =
        let elt = get_unique_elt "SetCss.borderBottomStyle" elt in
        elt##.style##.borderBottomStyle := Js.bytestring v

      let borderBottomWidth elt v =
        let elt = get_unique_elt "SetCss.borderBottomWidth" elt in
        elt##.style##.borderBottomWidth := Js.bytestring v

      let borderBottomWidthPx elt v =
        borderBottomWidth elt (Printf.sprintf "%dpx" v)

      let borderCollapse elt v =
        let elt = get_unique_elt "SetCss.borderCollapse" elt in
        elt##.style##.borderCollapse := Js.bytestring v

      let borderColor elt v =
        let elt = get_unique_elt "SetCss.borderColor" elt in
        elt##.style##.borderColor := Js.bytestring v

      let borderLeft elt v =
        let elt = get_unique_elt "SetCss.borderLeft" elt in
        elt##.style##.borderLeft := Js.bytestring v

      let borderLeftColor elt v =
        let elt = get_unique_elt "SetCss.borderLeftColor" elt in
        elt##.style##.borderLeftColor := Js.bytestring v

      let borderLeftStyle elt v =
        let elt = get_unique_elt "SetCss.borderLeftStyle" elt in
        elt##.style##.borderLeftStyle := Js.bytestring v

      let borderLeftWidth elt v =
        let elt = get_unique_elt "SetCss.borderLeftWidth" elt in
        elt##.style##.borderLeftWidth := Js.bytestring v

      let borderLeftWidthPx elt v =
        borderLeftWidth elt (Printf.sprintf "%dpx" v)

      let borderRight elt v =
        let elt = get_unique_elt "SetCss.borderRight" elt in
        elt##.style##.borderRight := Js.bytestring v

      let borderRightColor elt v =
        let elt = get_unique_elt "SetCss.borderRightColor" elt in
        elt##.style##.borderRightColor := Js.bytestring v

      let borderRightStyle elt v =
        let elt = get_unique_elt "SetCss.borderRightStyle" elt in
        elt##.style##.borderRightStyle := Js.bytestring v

      let borderRightWidth elt v =
        let elt = get_unique_elt "SetCss.borderRightWidth" elt in
        elt##.style##.borderRightWidth := Js.bytestring v

      let borderRightWidthPx elt v =
        borderRightWidth elt (Printf.sprintf "%dpx" v)

      let borderSpacing elt v =
        let elt = get_unique_elt "SetCss.borderSpacing" elt in
        elt##.style##.borderSpacing := Js.bytestring v

      let borderStyle elt v =
        let elt = get_unique_elt "SetCss.borderStyle" elt in
        elt##.style##.borderStyle := Js.bytestring v

      let borderTop elt v =
        let elt = get_unique_elt "SetCss.borderTop" elt in
        elt##.style##.borderTop := Js.bytestring v

      let borderTopColor elt v =
        let elt = get_unique_elt "SetCss.borderTopColor" elt in
        elt##.style##.borderTopColor := Js.bytestring v

      let borderTopStyle elt v =
        let elt = get_unique_elt "SetCss.borderTopStyle" elt in
        elt##.style##.borderTopStyle := Js.bytestring v

      let borderTopWidth elt v =
        let elt = get_unique_elt "SetCss.borderTopWidth" elt in
        elt##.style##.borderTopWidth := Js.bytestring v

      let borderTopWidthPx elt v = borderTopWidth elt (Printf.sprintf "%dpx" v)

      let borderWidth elt v =
        let elt = get_unique_elt "SetCss.borderWidth" elt in
        elt##.style##.borderWidth := Js.bytestring v

      let bottom elt v =
        let elt = get_unique_elt "SetCss.bottom" elt in
        elt##.style##.bottom := Js.bytestring v

      let bottomPx elt v = bottom elt (Printf.sprintf "%dpx" v)

      let captionSide elt v =
        let elt = get_unique_elt "SetCss.captionSide" elt in
        elt##.style##.captionSide := Js.bytestring v

      let clear elt v =
        let elt = get_unique_elt "SetCss.clear" elt in
        elt##.style##.clear := Js.bytestring v

      let clip elt v =
        let elt = get_unique_elt "SetCss.clip" elt in
        elt##.style##.clip := Js.bytestring v

      let color elt v =
        let elt = get_unique_elt "SetCss.color" elt in
        elt##.style##.color := Js.bytestring v

      let content elt v =
        let elt = get_unique_elt "SetCss.content" elt in
        elt##.style##.content := Js.bytestring v

      let counterIncrement elt v =
        let elt = get_unique_elt "SetCss.counterIncrement" elt in
        elt##.style##.counterIncrement := Js.bytestring v

      let counterReset elt v =
        let elt = get_unique_elt "SetCss.counterReset" elt in
        elt##.style##.counterReset := Js.bytestring v

      let cssFloat elt v =
        let elt = get_unique_elt "SetCss.cssFloat" elt in
        elt##.style##.cssFloat := Js.bytestring v

      let cssText elt v =
        let elt = get_unique_elt "SetCss.cssText" elt in
        elt##.style##.cssText := Js.bytestring v

      let cursor elt v =
        let elt = get_unique_elt "SetCss.cursor" elt in
        elt##.style##.cursor := Js.bytestring v

      let direction elt v =
        let elt = get_unique_elt "SetCss.direction" elt in
        elt##.style##.direction := Js.bytestring v

      let display elt v =
        let elt = get_unique_elt "SetCss.display" elt in
        elt##.style##.display := Js.bytestring v

      let emptyCells elt v =
        let elt = get_unique_elt "SetCss.emptyCells" elt in
        elt##.style##.emptyCells := Js.bytestring v

      let font elt v =
        let elt = get_unique_elt "SetCss.font" elt in
        elt##.style##.font := Js.bytestring v

      let fontFamily elt v =
        let elt = get_unique_elt "SetCss.fontFamily" elt in
        elt##.style##.fontFamily := Js.bytestring v

      let fontSize elt v =
        let elt = get_unique_elt "SetCss.fontSize" elt in
        elt##.style##.fontSize := Js.bytestring v

      let fontStyle elt v =
        let elt = get_unique_elt "SetCss.fontStyle" elt in
        elt##.style##.fontStyle := Js.bytestring v

      let fontVariant elt v =
        let elt = get_unique_elt "SetCss.fontVariant" elt in
        elt##.style##.fontVariant := Js.bytestring v

      let fontWeight elt v =
        let elt = get_unique_elt "SetCss.fontWeight" elt in
        elt##.style##.fontWeight := Js.bytestring v

      let height elt v =
        let elt = get_unique_elt "SetCss.height" elt in
        elt##.style##.height := Js.bytestring v

      let heightPx elt v = height elt (Printf.sprintf "%dpx" v)

      let left elt v =
        let elt = get_unique_elt "SetCss.left" elt in
        elt##.style##.left := Js.bytestring v

      let leftPx elt v = left elt (Printf.sprintf "%dpx" v)

      let letterSpacing elt v =
        let elt = get_unique_elt "SetCss.letterSpacing" elt in
        elt##.style##.letterSpacing := Js.bytestring v

      let lineHeight elt v =
        let elt = get_unique_elt "SetCss.lineHeight" elt in
        elt##.style##.lineHeight := Js.bytestring v

      let listStyle elt v =
        let elt = get_unique_elt "SetCss.listStyle" elt in
        elt##.style##.listStyle := Js.bytestring v

      let listStyleImage elt v =
        let elt = get_unique_elt "SetCss.listStyleImage" elt in
        elt##.style##.listStyleImage := Js.bytestring v

      let listStylePosition elt v =
        let elt = get_unique_elt "SetCss.listStylePosition" elt in
        elt##.style##.listStylePosition := Js.bytestring v

      let listStyleType elt v =
        let elt = get_unique_elt "SetCss.listStyleType" elt in
        elt##.style##.listStyleType := Js.bytestring v

      let margin elt v =
        let elt = get_unique_elt "SetCss.margin" elt in
        elt##.style##.margin := Js.bytestring v

      let marginBottom elt v =
        let elt = get_unique_elt "SetCss.marginBottom" elt in
        elt##.style##.marginBottom := Js.bytestring v

      let marginBottomPx elt v = marginBottom elt (Printf.sprintf "%dpx" v)

      let marginLeft elt v =
        let elt = get_unique_elt "SetCss.marginLeft" elt in
        elt##.style##.marginLeft := Js.bytestring v

      let marginLeftPx elt v = marginLeft elt (Printf.sprintf "%dpx" v)

      let marginRight elt v =
        let elt = get_unique_elt "SetCss.marginRight" elt in
        elt##.style##.marginRight := Js.bytestring v

      let marginRightPx elt v = marginRight elt (Printf.sprintf "%dpx" v)

      let marginTop elt v =
        let elt = get_unique_elt "SetCss.marginTop" elt in
        elt##.style##.marginTop := Js.bytestring v

      let marginTopPx elt v = marginTop elt (Printf.sprintf "%dpx" v)

      let maxHeight elt v =
        let elt = get_unique_elt "SetCss.maxHeight" elt in
        elt##.style##.maxHeight := Js.bytestring v

      let maxHeightPx elt v = maxHeight elt (Printf.sprintf "%dpx" v)

      let maxWidth elt v =
        let elt = get_unique_elt "SetCss.maxWidth" elt in
        elt##.style##.maxWidth := Js.bytestring v

      let maxWidthPx elt v = maxWidth elt (Printf.sprintf "%dpx" v)

      let minHeight elt v =
        let elt = get_unique_elt "SetCss.minHeight" elt in
        elt##.style##.minHeight := Js.bytestring v

      let minHeightPx elt v = minHeight elt (Printf.sprintf "%dpx" v)

      let minWidth elt v =
        let elt = get_unique_elt "SetCss.minWidth" elt in
        elt##.style##.minWidth := Js.bytestring v

      let minWidthPx elt v = minWidth elt (Printf.sprintf "%dpx" v)

      let opacity elt v =
        let elt = get_unique_elt "SetCss.opacity" elt in
        elt##.style##.opacity := Js.def (Js.bytestring v)

      let outline elt v =
        let elt = get_unique_elt "SetCss.outline" elt in
        elt##.style##.outline := Js.bytestring v

      let outlineColor elt v =
        let elt = get_unique_elt "SetCss.outlineColor" elt in
        elt##.style##.outlineColor := Js.bytestring v

      let outlineOffset elt v =
        let elt = get_unique_elt "SetCss.outlineOffset" elt in
        elt##.style##.outlineOffset := Js.bytestring v

      let outlineStyle elt v =
        let elt = get_unique_elt "SetCss.outlineStyle" elt in
        elt##.style##.outlineStyle := Js.bytestring v

      let outlineWidth elt v =
        let elt = get_unique_elt "SetCss.outlineWidth" elt in
        elt##.style##.outlineWidth := Js.bytestring v

      let overflow elt v =
        let elt = get_unique_elt "SetCss.overflow" elt in
        elt##.style##.overflow := Js.bytestring v

      let overflowX elt v =
        let elt = get_unique_elt "SetCss.overflowX" elt in
        elt##.style##.overflowX := Js.bytestring v

      let overflowY elt v =
        let elt = get_unique_elt "SetCss.overflowY" elt in
        elt##.style##.overflowY := Js.bytestring v

      let padding elt v =
        let elt = get_unique_elt "SetCss.padding" elt in
        elt##.style##.padding := Js.bytestring v

      let paddingBottom elt v =
        let elt = get_unique_elt "SetCss.paddingBottom" elt in
        elt##.style##.paddingBottom := Js.bytestring v

      let paddingBottomPx elt v = paddingBottom elt (Printf.sprintf "%dpx" v)

      let paddingLeft elt v =
        let elt = get_unique_elt "SetCss.paddingLeft" elt in
        elt##.style##.paddingLeft := Js.bytestring v

      let paddingLeftPx elt v = paddingLeft elt (Printf.sprintf "%dpx" v)

      let paddingRight elt v =
        let elt = get_unique_elt "SetCss.paddingRight" elt in
        elt##.style##.paddingRight := Js.bytestring v

      let paddingRightPx elt v = paddingRight elt (Printf.sprintf "%dpx" v)

      let paddingTop elt v =
        let elt = get_unique_elt "SetCss.paddingTop" elt in
        elt##.style##.paddingTop := Js.bytestring v

      let paddingTopPx elt v = paddingTop elt (Printf.sprintf "%dpx" v)

      let pageBreakAfter elt v =
        let elt = get_unique_elt "SetCss.pageBreakAfter" elt in
        elt##.style##.pageBreakAfter := Js.bytestring v

      let pageBreakBefore elt v =
        let elt = get_unique_elt "SetCss.pageBreakBefore" elt in
        elt##.style##.pageBreakBefore := Js.bytestring v

      let position elt v =
        let elt = get_unique_elt "SetCss.position" elt in
        elt##.style##.position := Js.bytestring v

      let right elt v =
        let elt = get_unique_elt "SetCss.right" elt in
        elt##.style##.right := Js.bytestring v

      let rightPx elt v = right elt (Printf.sprintf "%dpx" v)

      let tableLayout elt v =
        let elt = get_unique_elt "SetCss.tableLayout" elt in
        elt##.style##.tableLayout := Js.bytestring v

      let textAlign elt v =
        let elt = get_unique_elt "SetCss.textAlign" elt in
        elt##.style##.textAlign := Js.bytestring v

      let textDecoration elt v =
        let elt = get_unique_elt "SetCss.textDecoration" elt in
        elt##.style##.textDecoration := Js.bytestring v

      let textIndent elt v =
        let elt = get_unique_elt "SetCss.textIndent" elt in
        elt##.style##.textIndent := Js.bytestring v

      let textTransform elt v =
        let elt = get_unique_elt "SetCss.textTransform" elt in
        elt##.style##.textTransform := Js.bytestring v

      let top elt v =
        let elt = get_unique_elt "SetCss.top" elt in
        elt##.style##.top := Js.bytestring v

      let topPx elt v = top elt (Printf.sprintf "%dpx" v)

      let verticalAlign elt v =
        let elt = get_unique_elt "SetCss.verticalAlign" elt in
        elt##.style##.verticalAlign := Js.bytestring v

      let visibility elt v =
        let elt = get_unique_elt "SetCss.visibility" elt in
        elt##.style##.visibility := Js.bytestring v

      let whiteSpace elt v =
        let elt = get_unique_elt "SetCss.whiteSpace" elt in
        elt##.style##.whiteSpace := Js.bytestring v

      let width elt v =
        let elt = get_unique_elt "SetCss.width" elt in
        elt##.style##.width := Js.bytestring v

      let widthPx elt v = width elt (Printf.sprintf "%dpx" v)

      let wordSpacing elt v =
        let elt = get_unique_elt "SetCss.wordSpacing" elt in
        elt##.style##.wordSpacing := Js.bytestring v

      let zIndex elt v =
        let elt = get_unique_elt "SetCss.zIndex" elt in
        elt##.style##.zIndex := Js.bytestring v
    end
  end
end
OCaml

Innovation. Community. Security.