-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMain.purs
executable file
·1069 lines (904 loc) · 53.6 KB
/
Main.purs
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
module Test.Main where
import Prelude
import Data.Array as DA
import Data.Generic.Rep (class Generic)
import Data.Show.Generic as DSG
import Data.Maybe (Maybe(..))
import Data.Maybe as DM
import Data.Newtype (class Newtype)
import Data.String.CodeUnits as DSC
import Data.Tuple (Tuple(..))
import Data.Traversable as DT
import Effect (Effect)
import Effect.Aff (Milliseconds(..))
import Effect.Aff as AF
import Effect.Class (liftEffect)
import Effect.Exception.Unsafe as EEU
import Effect.Uncurried (EffectFn2)
import Effect.Uncurried as EU
import Flame.Application.Effectful as FAE
import Flame.Application.Internal.Dom as FAD
import Flame.Html.Attribute as HA
import Flame.Html.Element as HE
import Flame.Renderer.Internal.Dom as FRID
import Flame.Renderer.String as FRS
import Flame.Subscription as FS
import Flame.Subscription.Unsafe.CustomEvent as FSUC
import Partial.Unsafe (unsafePartial)
import Test.Basic.EffectList as TBEL
import Test.Basic.Effectful as TBE
import Test.Functor.Basic as TBF
import Test.Functor.Lazy as TFL
import Test.Basic.NoEffects as TBN
import Test.Effectful.SlowEffects as TES
import Test.ServerSideRendering.Effectful as TSE
import Test.ServerSideRendering.FragmentNode as TSF
import Test.ServerSideRendering.ManagedNode as TSM
import Test.Subscription.Broadcast as TSB
import Test.Subscription.EffectList (TEELMessage(..))
import Test.Subscription.EffectList as TEEL
import Test.Subscription.Effectful as TEE
import Test.Subscription.NoEffects as TEN
import Unsafe.Coerce as UC
import Web.DOM.Element (Element)
import Web.DOM.Element as WDE
import Web.DOM.HTMLCollection as WDHC
import Web.DOM.Node (Node)
import Web.DOM.Node as WDN
import Web.DOM.ParentNode as WDP
import Web.Event.Event (EventType(..))
import Web.Event.EventTarget as WEE
import Web.Event.Internal.Types (Event)
import Web.HTML as WH
import Web.HTML.HTMLDocument as WDD
import Web.HTML.HTMLInputElement as WHH
import Test.Spec.Assertions as TSA
import Test.Spec as TS
import Web.HTML.Window as WHW
import Test.Spec.Runner as TSR
import Test.Spec.Reporter.Console (consoleReporter)
--we use jsdom to provide a browser like enviroment to run tests
-- as of now, dom objects are copied to the global object, as it is easier than having to mess with browersification
-- and headless browers
foreign import unsafeCreateEnviroment ∷ Effect Unit
foreign import clickEvent ∷ Effect Event
foreign import inputEvent ∷ Effect Event
foreign import keydownEvent ∷ Effect Event
foreign import enterPressedEvent ∷ Effect Event
foreign import errorEvent ∷ Effect Event
foreign import offlineEvent ∷ Effect Event
foreign import getCssText ∷ Element → String
foreign import getAllAttributes ∷ Element → String
foreign import getAllProperties ∷ Element → Array String → Array String
foreign import innerHtml_ ∷ EffectFn2 Element String Unit
foreign import createSvg ∷ Effect Node
foreign import createDiv ∷ Effect Node
main ∷ Effect Unit
main = AF.launchAff_ $ TSR.runSpec [ consoleReporter ] do
TS.describe "Server side virtual node creation" do
TS.it "ToHtml instances" do
let html = HE.a [ HA.id "test" ] [ HE.text "TEST" ]
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<a id="test">TEST</a>""" html'
let html2 = HE.a (HA.id "test") [ HE.text "TEST" ]
html2' ← liftEffect $ FRS.render html2
TSA.shouldEqual """<a id="test">TEST</a>""" html2'
let html3 = HE.kbd "test" [ HE.text "TEST" ]
html3' ← liftEffect $ FRS.render html3
TSA.shouldEqual """<kbd id="test">TEST</kbd>""" html3'
let html4 = HE.a "test" $ HE.text "TEST"
html4' ← liftEffect $ FRS.render html4
TSA.shouldEqual """<a id="test">TEST</a>""" html4'
let html5 = HE.a "test" "TEST"
html5' ← liftEffect $ FRS.render html5
TSA.shouldEqual """<a id="test">TEST</a>""" html5'
TS.it "ToClassList instances" do
let html = HE.a [ HA.class' "test" ] [ HE.text "TEST" ]
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<a class="test">TEST</a>""" html'
let html2 = HE.svg [ HA.class' { "test": false, "test2": true, "test3": true } ] [ HE.text "TEST" ]
html2' ← liftEffect $ FRS.render html2
TSA.shouldEqual """<svg class="test2 test3">TEST</svg>""" html2'
TS.it "inline style" do
let html = HE.a (HA.style { mystyle: "test" }) [ HE.text "TEST" ]
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<a style="mystyle: test">TEST</a>""" html'
let html2 = HE.a [ HA.style { width: "23px", display: "none" } ] [ HE.text "TEST" ]
html2' ← liftEffect $ FRS.render html2
TSA.shouldEqual """<a style="width: 23px; display: none">TEST</a>""" html2'
let html3 = HE.a (HA.style1 "mystyle" "test-test") [ HE.text "TEST" ]
html3' ← liftEffect $ FRS.render html3
TSA.shouldEqual """<a style="mystyle: test-test">TEST</a>""" html3'
TS.it "styles merge" do
let html = HE.a [ HA.style { mystyle: "test", mylife: "good" }, HA.style { mystyle: "check" } ] [ HE.text "TEST" ]
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<a style="mystyle: check; mylife: good">TEST</a>""" html'
let html2 = HE.a [ HA.style { width: "23px", display: "none" }, HA.style { height: "10px" } ] [ HE.text "TEST" ]
html2' ← liftEffect $ FRS.render html2
TSA.shouldEqual """<a style="width: 23px; display: none; height: 10px">TEST</a>""" html2'
let html3 = HE.a [ HA.style [ Tuple "width" "64px", Tuple "display" "none" ], HA.style (Tuple "height" "10px") ] [ HE.text "TEST" ]
html3' ← liftEffect $ FRS.render html3
TSA.shouldEqual """<a style="width: 64px; display: none; height: 10px">TEST</a>""" html3'
TS.it "classes merge" do
let html = HE.a [ HA.class' "a b", HA.class' { c: true } ] [ HE.text "TEST" ]
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<a class="a b c">TEST</a>""" html'
TS.it "style/class name case" do
html ← liftEffect <<< FRS.render $ HE.createElement' "element" $ HA.class' "superClass"
TSA.shouldEqual """<element class="super-class"></element>""" html
html2 ← liftEffect <<< FRS.render $ HE.createElement' "element" $ HA.class' "SuperClass"
TSA.shouldEqual """<element class="super-class"></element>""" html2
html3 ← liftEffect <<< FRS.render $ HE.createElement' "element" $ HA.class' "MySuperClass my-other-class"
TSA.shouldEqual """<element class="my-super-class my-other-class"></element>""" html3
html4 ← liftEffect <<< FRS.render $ HE.createElement' "element" $ HA.class' "SUPERCLASS"
TSA.shouldEqual """<element class="superclass"></element>""" html4
html5 ← liftEffect <<< FRS.render $ HE.createElement' "element" $ HA.style { borderBox: "23", s: "34", borderLeftTopRadius: "20px" }
TSA.shouldEqual """<element style="border-box: 23; s: 34; border-left-top-radius: 20px"></element>""" html5
html6 ← liftEffect <<< FRS.render $ HE.createElement' "element" $ HA.class' { borderBox: true, s: false, borderLeftTopRadius: true }
TSA.shouldEqual """<element class="border-box border-left-top-radius"></element>""" html6
TS.it "custom elements" do
let html = HE.createElement' "custom-element" "test"
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<custom-element id="test"></custom-element>""" html'
let html2 = HE.createElement' "custom-element" "test"
html2' ← liftEffect $ FRS.render html2
TSA.shouldEqual """<custom-element id="test"></custom-element>""" html2'
let html3 = HE.createElement_ "custom-element" "test"
html3' ← liftEffect $ FRS.render html3
TSA.shouldEqual """<custom-element>test</custom-element>""" html3'
TS.it "lazy nodes" do
let html = HE.lazy Nothing (const (HE.p [ HA.id "p", HA.min "23" ] "TEST")) unit
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<p id="p" min="23">TEST</p>""" html'
TS.it "fragment nodes" do
let
html = HE.fragment
[ HE.a [ HA.class' "test" ] [ HE.text "TEST" ]
, HE.a [ HA.class' "test-2" ] [ HE.text "TEST-2" ]
]
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<a class="test">TEST</a><a class="test-2">TEST-2</a>""" html'
TS.it "svg nodes" do
let html = HE.svg [ HA.id "oi", HA.class' "ola", HA.viewBox "0 0 23 0" ] <<< HE.path' $ HA.d "234"
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<svg class="ola" id="oi" viewBox="0 0 23 0"><path d="234" /></svg>""" html'
TS.it "managed nodes are ignored" do
let html = HE.div [ HA.class' "a b" ] $ HE.managed_ { createNode: const createDiv, updateNode: \e _ _ → pure e } unit
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<div class="a b"></div>""" html'
TS.it "nested elements" do
let
html = HE.html_
[ HE.head_ [ HE.title "title" ]
, HE.body_
[ HE.main_
[ HE.button_ "-"
, HE.br
, HE.text "Test"
, HE.button_ "+"
, HE.svg (HA.viewBox "0 0 23 0") <<< HE.path' $ HA.d "234"
, HE.div_ $ HE.div_
[ HE.span_ [ HE.a_ "here" ]
]
]
]
]
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<!DOCTYPE html><html><head><title>title</title></head><body><main><button>-</button><br>Test<button>+</button><svg viewBox="0 0 23 0"><path d="234" /></svg><div><div><span><a>here</a></span></div></div></main></body></html>""" html'
TS.it "nested nodes with attributes" do
let
html = HE.html [ HA.lang "en" ]
[ HE.head_ [ HE.title "title" ]
, HE.body "content"
[ HE.main_
[ HE.button (HA.style { display: "block", width: "20px" }) "-"
, HE.br
, HE.text "Test"
, HE.button (HA.createAttribute "my-attribute" "myValue") "+"
, HE.hr' [ HA.style { border: "200px solid blue" } ]
, HE.div_ $ HE.div_
[ HE.span_ [ HE.a_ "here" ]
]
]
]
]
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<!DOCTYPE html><html lang="en"><head><title>title</title></head><body id="content"><main><button style="display: block; width: 20px">-</button><br>Test<button my-attribute="myValue">+</button><hr style="border: 200px solid blue"><div><div><span><a>here</a></span></div></div></main></body></html>""" html'
TS.it "nested nodes with properties and attributes" do
let
html = HE.html [ HA.lang "en" ]
[ HE.head [ HA.disabled true ] [ HE.title "title" ]
, HE.body "content"
[ HE.lazy Nothing
( const
( HE.main_
[ HE.button (HA.style { display: "block", width: "20px" }) "-"
, HE.br
, HE.text "Test"
, HE.button (HA.createAttribute "my-attribute" "myValue") "+"
, HE.hr' [ HA.autocomplete "off", HA.style { border: "200px solid blue" } ]
, HE.div_ $ HE.div_
[
--empty data should not be rendered
HE.span (HA.class' "") [ HE.a [ HA.autofocus true ] "here" ]
]
]
)
)
unit
]
]
html' ← liftEffect $ FRS.render html
TSA.shouldEqual """<!DOCTYPE html><html lang="en"><head disabled="disabled"><title>title</title></head><body id="content"><main><button style="display: block; width: 20px">-</button><br>Test<button my-attribute="myValue">+</button><hr style="border: 200px solid blue" autocomplete="off"><div><div><span><a autofocus="autofocus">here</a></span></div></div></main></body></html>""" html'
TS.describe "root node" do
TS.it "root node is unchanged" do
liftEffect unsafeCreateEnviroment
let html = HE.div "test-div" $ HE.input [ HA.id "t", HA.value "a" ]
void $ mountHtml' html
rootNode ← liftEffect $ FAD.querySelector "#mount-point"
TSA.shouldSatisfy rootNode DM.isJust
TS.it "root node external children are unchanged" do
liftEffect unsafeCreateEnviroment
rootNode ← liftEffect $ unsafeQuerySelector "#mount-point"
liftEffect $ innerHtml rootNode """<div id="oi"></div>"""
let html = HE.div "test-div" $ HE.input [ HA.id "t", HA.value "a" ]
state ← mountHtml' html
childrenCount ← childrenNodeLengthOf "#mount-point"
TSA.shouldEqual 2 childrenCount
divNode ← liftEffect $ FAD.querySelector "#oi"
TSA.shouldSatisfy divNode DM.isJust
--we also have to test the translation of virtual nodes to actual dom nodes
TS.describe "DOM node creation" do
TS.it "styles" do
let html = HE.a [ HA.id "link", HA.style { border: "solid", margin: "0px" } ] "TEST"
state ← mountHtml html
nodeStyle ← getStyle "#link"
TSA.shouldEqual "border: solid; margin: 0px;" nodeStyle
let updatedHtml = HE.a [ HA.id "link", HA.style { border: "2px", padding: "23px" } ] "TEST"
liftEffect $ FRID.resume state updatedHtml
updatedNodeStyle ← getStyle "#link"
TSA.shouldEqual "border: 2px; padding: 23px;" updatedNodeStyle
let emptyUpdatedHtml = HE.a [ HA.id "link", HA.style {} ] "TEST"
liftEffect $ FRID.resume state emptyUpdatedHtml
emptyUpdatedNodeStyle ← getStyle "#link"
TSA.shouldEqual "" emptyUpdatedNodeStyle
let fullUpdatedHtml = HE.a [ HA.id "link", HA.style { "z-index": "3" } ] "TEST"
liftEffect $ FRID.resume state fullUpdatedHtml
fullNodeStyle ← getStyle "#link"
TSA.shouldEqual "z-index: 3;" fullNodeStyle
TS.it "element classes" do
let html = HE.p (HA.class' "firstClass secondClass thirdClass") "TEST"
state ← mountHtml html
nodeClass ← getClass "p"
TSA.shouldEqual "first-class second-class third-class" nodeClass
let updatedHtml = HE.p (HA.class' { firstClass: false }) "TEST"
liftEffect $ FRID.resume state updatedHtml
updatedNodeClass ← getClass "p"
TSA.shouldEqual "" updatedNodeClass
let emptyUpdatedHtml = HE.p (HA.class' "") "TEST"
liftEffect $ FRID.resume state emptyUpdatedHtml
emptyUpdatedNodeClass ← getClass "p"
TSA.shouldEqual "" emptyUpdatedNodeClass
let fullUpdatedHtml = HE.p (HA.class' { some: true, some2: true }) "TEST"
liftEffect $ FRID.resume state fullUpdatedHtml
fullNodeClass ← getClass "p"
TSA.shouldEqual "some some2" fullNodeClass
TS.it "svg classes" do
let html = HE.svg (HA.class' "firstClass secondClass thirdClass") "TEST"
state ← mountHtml html
nodeClass ← getSvgClass "svg"
TSA.shouldEqual (Just "first-class second-class third-class") nodeClass
let updatedHtml = HE.svg (HA.class' { firstClass: false }) "TEST"
liftEffect $ FRID.resume state updatedHtml
updatedNodeClass ← getSvgClass "svg"
TSA.shouldEqual (Just "") updatedNodeClass
let emptyUpdatedHtml = HE.svg (HA.class' "") "TEST"
liftEffect $ FRID.resume state emptyUpdatedHtml
emptyUpdatedNodeClass ← getSvgClass "svg"
TSA.shouldEqual (Just "") emptyUpdatedNodeClass
let fullUpdatedHtml = HE.svg (HA.class' { some: true, some2: true }) "TEST"
liftEffect $ FRID.resume state fullUpdatedHtml
fullNodeClass ← getSvgClass "svg"
TSA.shouldEqual (Just "some some2") fullNodeClass
TS.it "attributes" do
let html = HE.input [ HA.id "t", HA.href "e.com", HA.max "oi" ]
state ← mountHtml html
nodeAttributes ← getAttributes "#t"
TSA.shouldEqual "href:e.com max:oi id:t" nodeAttributes
let updatedHtml = HE.input [ HA.id "t", HA.href "e.com", HA.min "ola", HA.ping "pong" ]
liftEffect $ FRID.resume state updatedHtml
updatedNodeAttributes ← getAttributes "#t"
TSA.shouldEqual "href:e.com id:t min:ola ping:pong" updatedNodeAttributes
let emptyUpdatedHtml = HE.input [ HA.id "t" ]
liftEffect $ FRID.resume state emptyUpdatedHtml
emptyUpdatedNodeAttributes ← getAttributes "#t"
--id is a property that also has an attribute
TSA.shouldEqual "id:t" emptyUpdatedNodeAttributes
let fullUpdatedHtml = HE.input [ HA.id "t", HA.href "e.com", HA.min "ola", HA.ping "pong" ]
liftEffect $ FRID.resume state fullUpdatedHtml
fullNodeAttributes ← getAttributes "#t"
TSA.shouldEqual "id:t href:e.com min:ola ping:pong" fullNodeAttributes
TS.it "presential attributes" do
let html = HE.input [ HA.id "t", HA.type' "checkbox", HA.disabled true, HA.autofocus true ]
state ← mountHtml html
nodeAttributes ← getAttributes "input"
TSA.shouldEqual "id:t type:checkbox disabled: autofocus:" nodeAttributes
let updatedHtml = HE.input [ HA.id "t", HA.type' "checkbox", HA.disabled false, HA.autofocus true ]
liftEffect $ FRID.resume state updatedHtml
updatedNodeAttributes ← getAttributes "input"
TSA.shouldEqual "id:t type:checkbox autofocus:" updatedNodeAttributes
TS.it "properties" do
let html = HE.input [ HA.id "t", HA.value "a" ]
state ← mountHtml html
nodeProperties ← getProperties "input" [ "id", "value" ]
TSA.shouldEqual [ "t", "a" ] nodeProperties
let updatedHtml = HE.input [ HA.id "q", HA.pattern "aaa" ]
liftEffect $ FRID.resume state updatedHtml
updatedNodeProperties ← getProperties "input" [ "id", "pattern" ]
TSA.shouldEqual [ "q", "aaa" ] updatedNodeProperties
TS.it "text property of lazy nodes" do
let html = HE.lazy Nothing (const (HE.div_ "oi")) unit
void $ mountHtml html
text ← textContent "#mount-point"
TSA.shouldEqual "oi" text
TS.it "nested svg elements have correct namespace" do
let
html = HE.svg
[ HA.viewBox "0 0 100 100"
, HA.createAttribute "xmlns" "http://www.w3.org/2000/svg"
]
[ HE.g [ HA.fill "white", HA.stroke "green", HA.strokeWidth "5" ]
[ HE.circle' [ HA.cx "40", HA.cy "40", HA.r "25" ], HE.circle' [ HA.cx "60", HA.cy "60", HA.r "25" ] ]
]
void $ mountHtml html
let
verifyNodeAndChildren node = do
TSA.shouldEqual (Just "http://www.w3.org/2000/svg") (WDE.namespaceURI node)
children ← liftEffect $ childrenNode' node
DT.for_ children verifyNodeAndChildren
svg ← liftEffect $ unsafeQuerySelector "svg"
verifyNodeAndChildren svg
TS.describe "dom node update" do
TS.it "update text nodes" do
let html = HE.text "oi"
state ← mountHtml html
text ← textContent "#mount-point"
TSA.shouldEqual "oi" text
let updatedHtml = HE.text "ola"
liftEffect $ FRID.resume state updatedHtml
updatedText ← textContent "#mount-point"
TSA.shouldEqual "ola" updatedText
TS.it "unset text property" do
--nodes with a single text node child have the textContent property set
let html = HE.div "test-div" "oi"
state ← mountHtml html
text ← textContent "#test-div"
TSA.shouldEqual "oi" text
let updatedHtml = HE.div' "test-div"
liftEffect $ FRID.resume state updatedHtml
text2 ← textContent "#test-div"
TSA.shouldEqual "" text2
TS.it "text to children" do
--nodes with a single text node child have the textContent property set
let html = HE.div "test-div" "oi"
state ← mountHtml html
text ← textContent "#test-div"
TSA.shouldEqual "oi" text
let updatedHtml = HE.div "test-div" [ HE.span_ "ola", HE.div_ "hah", HE.br ]
liftEffect $ FRID.resume state updatedHtml
text2 ← textContent "#test-div"
--from children
TSA.shouldEqual "olahah" text2
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 3 childrenCount
TS.it "children to text" do
--nodes with a single text node child have the textContent property set
let html = HE.div "test-div" [ HE.span_ "ola", HE.div_ "hah", HE.br ]
state ← mountHtml html
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 3 childrenCount
let updatedHtml = HE.div "test-div" "oi"
liftEffect $ FRID.resume state updatedHtml
text ← textContent "#test-div"
TSA.shouldEqual "oi" text
childrenCount2 ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 0 childrenCount2
TS.it "update node tag" do
let html = HE.div "test-div" $ HE.input [ HA.id "t", HA.value "a" ]
state ← mountHtml html
let updatedHtml = HE.span (HA.class' "test-class") $ HE.input [ HA.id "t", HA.value "a" ]
liftEffect $ FRID.resume state updatedHtml
oldElement ← liftEffect $ FAD.querySelector "#test-div"
TSA.shouldSatisfy oldElement DM.isNothing
nodeClass ← getClass "span.test-class"
TSA.shouldEqual "test-class" nodeClass
TS.it "update node type" do
let html = HE.div "test-div" $ HE.input [ HA.id "t", HA.value "a" ]
state ← mountHtml html
let updatedHtml = HE.svg' (HA.viewBox "0 0 0 0")
liftEffect $ FRID.resume state updatedHtml
oldElement ← liftEffect $ FAD.querySelector "#test-div"
TSA.shouldSatisfy oldElement DM.isNothing
nodeAttributes ← getAttributes "svg"
TSA.shouldEqual "viewBox:0 0 0 0" nodeAttributes
TS.it "update fragment to node" do
let html = HE.div "test-div" [ HE.fragment [HE.input [ HA.id "t", HA.value "a" ], HE.br], HE.span_ "ss"]
state ← mountHtml html
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 3 childrenCount
let updatedHtml = HE.div "test-div" [ HE.div_ "aa", HE.span_ "ss"]
liftEffect $ FRID.resume state updatedHtml
childrenCount2 ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 2 childrenCount2
TS.it "inserting children" do
let html = HE.div' "test-div"
state ← mountHtml html
let updatedHtml = HE.div "test-div" [ HE.br, HE.hr ]
liftEffect $ FRID.resume state updatedHtml
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 2 childrenCount
TS.it "removing children" do
let html = HE.div "test-div" [ HE.br, HE.hr ]
state ← mountHtml html
let updatedHtml = HE.div' "test-div"
liftEffect $ FRID.resume state updatedHtml
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 0 childrenCount
TS.it "removing children with innerHtml" do
let html = HE.div "test-div" [ HE.br, HE.hr ]
state ← mountHtml html
let updatedHtml = HE.div' [ HA.id "test-div", HA.innerHtml "<p>oi</p>" ]
liftEffect $ FRID.resume state updatedHtml
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 1 childrenCount
p ← liftEffect $ FAD.querySelector "p"
TSA.shouldSatisfy p DM.isJust
TS.it "removing and inserting children with innerHtml" do
let html = HE.div' [ HA.id "test-div", HA.innerHtml "<p>oi</p>" ]
state ← mountHtml html
let updatedHtml = HE.div (HA.id "test-div") [ HE.br, HE.hr ]
liftEffect $ FRID.resume state updatedHtml
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 2 childrenCount
hr ← liftEffect $ FAD.querySelector "br"
TSA.shouldSatisfy hr DM.isJust
TS.it "fragments" do
let html = HE.div "test-div" $ HE.input [ HA.id "t", HA.value "a" ]
state ← mountHtml html
let updatedHtml = HE.fragment $ HE.lazy Nothing (const (HE.svg' (HA.viewBox "0 0 0 0"))) unit
liftEffect $ FRID.resume state updatedHtml
oldElement ← liftEffect $ FAD.querySelector "#test-div"
TSA.shouldSatisfy oldElement DM.isNothing
nodeAttributes ← getAttributes "svg"
TSA.shouldEqual "viewBox:0 0 0 0" nodeAttributes
TS.it "managed nodes" do
let html = HE.managed { createNode: const createSvg, updateNode: \_ _ _ → createSvg } [ HA.id "oi", HA.class' "ola", HA.viewBox "0 0 23 0" ] unit
state ← mountHtml html
svgElement ← liftEffect $ FAD.querySelector "svg"
TSA.shouldSatisfy svgElement DM.isJust
nodeAttributes ← getAttributes "svg"
TSA.shouldEqual "class:ola viewbox:0 0 23 0 id:oi" nodeAttributes
divElement ← liftEffect createDiv
liftEffect $ innerHtml (UC.unsafeCoerce divElement) """<span class="oi"></span>"""
let updatedHtml = HE.managed_ { createNode: const (pure divElement), updateNode: \e _ _ → pure divElement } unit
liftEffect $ FRID.resume state updatedHtml
oldElement ← liftEffect $ FAD.querySelector "svg"
TSA.shouldSatisfy oldElement DM.isNothing
divElementCreated ← liftEffect $ FAD.querySelector "#mount-point div"
TSA.shouldSatisfy divElementCreated DM.isJust
let updatedHtml2 = HE.managed { createNode: const (pure divElement), updateNode: \e _ _ → pure e } [ HA.class' "test" ] unit
liftEffect $ FRID.resume state updatedHtml2
spanElement ← liftEffect $ FAD.querySelector "span"
TSA.shouldSatisfy spanElement DM.isJust
nodeClass ← getClass "#mount-point div"
TSA.shouldEqual "test" nodeClass
TS.it "setting inner html" do
let html = HE.div_ $ HE.div' [ HA.id "test-div", HA.innerHtml "<span>Test</span>" ]
state ← mountHtml html
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 1 childrenCount
let updatedHtml = HE.main_ $ HE.div' [ HA.id "test-div", HA.innerHtml "<span>Test</span><hr>" ]
liftEffect $ FRID.resume state updatedHtml
childrenCount2 ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 2 childrenCount2
let updatedHtml2 = HE.main_ "oi"
liftEffect $ FRID.resume state updatedHtml2
oldElement ← liftEffect $ FAD.querySelector "#test-div"
TSA.shouldSatisfy oldElement DM.isNothing
TS.it "replacing child nodes (type)" do
let html = HE.div "test-div" $ HE.input [ HA.id "t", HA.value "a" ]
state ← mountHtml html
let updatedHtml = HE.div "test-div" $ HE.svg' (HA.viewBox "0 0 0 0")
liftEffect $ FRID.resume state updatedHtml
oldElement ← liftEffect $ FAD.querySelector "input"
TSA.shouldSatisfy oldElement DM.isNothing
nodeAttributes ← getAttributes "svg"
TSA.shouldEqual "viewBox:0 0 0 0" nodeAttributes
TS.it "replacing child nodes (tag)" do
let html = HE.div "test-div" $ HE.input [ HA.id "t", HA.value "a" ]
state ← mountHtml html
let updatedHtml = HE.div "test-div" $ HE.div_ "test"
liftEffect $ FRID.resume state updatedHtml
oldElement ← liftEffect $ FAD.querySelector "input"
TSA.shouldSatisfy oldElement DM.isNothing
nodeAttributes ← getAttributes "#test-div div"
TSA.shouldEqual "" nodeAttributes
TS.it "replacing child nodes (number of children)" do
let html = HE.div "test-div" [ HE.input [ HA.id "t", HA.value "a" ], HE.div (HA.class' "inside-div") "test", HE.span "test-span" $ HE.br ]
state ← mountHtml html
let updatedHtml = HE.div "test-div" [ HE.main_ "oi", HE.section_ $ HE.hr ]
liftEffect $ FRID.resume state updatedHtml
oldElements ← liftEffect $ DT.traverse FAD.querySelector [ "input", "#test-div div", "#test-div span" ]
TSA.shouldSatisfy oldElements (DA.all DM.isNothing)
nodeAttributes ← getAttributes "#test-div main"
TSA.shouldEqual "" nodeAttributes
nodeAttributes2 ← getAttributes "#test-div section"
TSA.shouldEqual "" nodeAttributes
TS.describe "events" do
TS.it "event sets dom property" do
let html = HE.input [ HA.onClick unit ]
state ← mountHtml html
nodeProperties ← getProperties "input" [ eventPrefix <> "click" ]
TSA.shouldSatisfy nodeProperties ((_ == 1) <<< DA.length)
TS.it "removing event also removes dom property" do
let html = HE.input [ HA.onClick unit, HA.onScroll unit ]
state ← mountHtml html
let updatedHtml = HE.input [ HA.onClick unit ]
liftEffect $ FRID.resume state updatedHtml
nodeProperties ← getProperties "input" [ eventPrefix <> "click", eventPrefix <> "scroll" ]
TSA.shouldSatisfy nodeProperties ((_ == 1) <<< DA.length)
TS.describe "keyed" do
TS.it "common prefix" do
let html = HE.div "test-div" [ HE.span' [ HA.key "1" ], HE.span' [ HA.key "2" ] ]
state ← mountHtml html
let updatedHtml = HE.div "test-div" [ HE.span' [ HA.key "1" ], HE.span' [ HA.key "2" ], HE.span' [ HA.key "3" ] ]
liftEffect $ FRID.resume state updatedHtml
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 3 childrenCount
TS.it "common suffix" do
let html = HE.div "test-div" [ HE.span' [ HA.key "2" ], HE.span' [ HA.key "3" ] ]
state ← mountHtml html
let updatedHtml = HE.div "test-div" [ HE.span' [ HA.key "1" ], HE.span' [ HA.key "2" ], HE.span' [ HA.key "3" ] ]
liftEffect $ FRID.resume state updatedHtml
childrenCount ← childrenNodeLengthOf "#test-div"
TSA.shouldEqual 3 childrenCount
TS.it "swap backwards" do
let html = HE.div "test-div" [ HE.span' [ HA.key "1", HA.id "1" ], HE.span' [ HA.key "2", HA.id "2" ], HE.span' [ HA.key "3", HA.id "3" ] ]
state ← mountHtml html
childrenIds ← childNodeIds "#test-div"
TSA.shouldEqual [ "1", "2", "3" ] childrenIds
let updatedHtml = HE.div "test-div" [ HE.span' [ HA.key "3", HA.id "3" ], HE.span' [ HA.key "2", HA.id "2" ], HE.span' [ HA.key "1", HA.id "1" ] ]
liftEffect $ FRID.resume state updatedHtml
childrenIdsSwapped ← childNodeIds "#test-div"
TSA.shouldEqual [ "3", "2", "1" ] childrenIdsSwapped
TS.it "swap forward" do
let html = HE.div "test-div" [ HE.span' [ HA.key "3", HA.id "3" ], HE.span' [ HA.key "2", HA.id "2" ], HE.span' [ HA.key "1", HA.id "1" ] ]
state ← mountHtml html
childrenIds ← childNodeIds "#test-div"
TSA.shouldEqual [ "3", "2", "1" ] childrenIds
let updatedHtml = HE.div "test-div" [ HE.span' [ HA.key "1", HA.id "1" ], HE.span' [ HA.key "2", HA.id "2" ], HE.span' [ HA.key "3", HA.id "3" ] ]
liftEffect $ FRID.resume state updatedHtml
childrenIdsSwapped ← childNodeIds "#test-div"
TSA.shouldEqual [ "1", "2", "3" ] childrenIdsSwapped
-- TS.it "remove nodes" do
-- TS.it "remove all nodes" do
-- TS.it "move nodes" do
-- TS.it "move and remove nodes" do
-- TS.it "move and add nodes" do
TS.describe "diff" do
TS.it "updates record fields" do
TSA.shouldEqual { a: 23, b: "hello", c: true } $ FAE.diff' { c: true } { a: 23, b: "hello", c: false }
TSA.shouldEqual { a: 23, b: "hello", c: false } $ FAE.diff' {} { a: 23, b: "hello", c: false }
TS.it "updates record fields with newtype" do
TSA.shouldEqual (TestNewtype { a: 23, b: "hello", c: true }) <<< FAE.diff' { c: true } $ TestNewtype { a: 23, b: "hello", c: false }
TSA.shouldEqual (TestNewtype { a: 23, b: "hello", c: false }) <<< FAE.diff' {} $ TestNewtype { a: 23, b: "hello", c: false }
TS.it "updates record fields with functor" do
TSA.shouldEqual (Just { a: 23, b: "hello", c: true }) <<< FAE.diff' { c: true } $ Just { a: 23, b: "hello", c: false }
TSA.shouldEqual (Just { a: 23, b: "hello", c: false }) <<< FAE.diff' {} $ Just { a: 23, b: "hello", c: false }
TS.it "new copy is returned" do
--since diff uses unsafe javascript, make sure the reference is not being written to
let model = { a: 1, b: 2 }
TSA.shouldEqual { a: 1, b: 3 } $ FAE.diff' { b: 3 } model
TSA.shouldEqual { a: 12, b: 2 } $ FAE.diff' { a: 12 } model
TS.describe "Basic applications" do
TS.it "noeffects" do
liftEffect do
unsafeCreateEnviroment
TBN.mount
childrenLength ← childrenNodeLength
--button, span, button
TSA.shouldEqual 3 childrenLength
initial ← textContent "#text-output"
TSA.shouldEqual "0" initial
dispatchEvent clickEvent "#decrement-button"
current ← textContent "#text-output"
TSA.shouldEqual "-1" current
dispatchEvent clickEvent "#increment-button"
dispatchEvent clickEvent "#increment-button"
current2 ← textContent "#text-output"
TSA.shouldEqual "1" current2
TS.it "effectlist" do
liftEffect do
unsafeCreateEnviroment
TBEL.mount
childrenLength ← childrenNodeLength
--span, input, input
TSA.shouldEqual 3 childrenLength
let
setInput text = liftEffect do
element ← unsafeQuerySelector "#text-input"
WHH.setValue text $ unsafePartial (DM.fromJust $ WHH.fromElement element)
initial ← textContent "#text-output"
TSA.shouldEqual "" initial
dispatchEvent clickEvent "#cut-button"
current ← textContent "#text-output"
TSA.shouldEqual "" current
setInput "test"
dispatchEvent inputEvent "#text-input"
dispatchEvent clickEvent "#cut-button"
cut ← textContent "#text-output"
--always remove at least one character
TSA.shouldSatisfy cut ((_ < 4) <<< DSC.length)
dispatchEvent inputEvent "#text-input"
dispatchEvent enterPressedEvent "#text-input"
submitted ← textContent "#text-output"
TSA.shouldEqual "thanks" submitted
TS.it "effectful" do
liftEffect do
unsafeCreateEnviroment
TBE.mount
childrenLength ← childrenNodeLength
--span, span, span, br, button, button
TSA.shouldEqual 6 childrenLength
currentIncrement ← textContent "#text-output-increment"
currentDecrement ← textContent "#text-output-decrement"
currentLuckyNumber ← textContent "#text-output-lucky-number"
TSA.shouldEqual "-1" currentDecrement
TSA.shouldEqual "0" currentIncrement
TSA.shouldEqual "2" currentLuckyNumber
dispatchEvent clickEvent "#decrement-button"
currentIncrement2 ← textContent "#text-output-increment"
currentDecrement2 ← textContent "#text-output-decrement"
currentLuckyNumber2 ← textContent "#text-output-lucky-number"
TSA.shouldEqual "-2" currentDecrement2
TSA.shouldEqual "0" currentIncrement2
TSA.shouldEqual "2" currentLuckyNumber2
dispatchEvent clickEvent "#increment-button"
dispatchEvent clickEvent "#increment-button"
currentIncrement3 ← textContent "#text-output-increment"
currentDecrement3 ← textContent "#text-output-decrement"
currentLuckyNumber3 ← textContent "#text-output-lucky-number"
TSA.shouldEqual "2" currentIncrement3
TSA.shouldEqual "-2" currentDecrement3
TSA.shouldEqual "2" currentLuckyNumber3
TS.describe "functor" do
TS.it "basic" do
liftEffect do
unsafeCreateEnviroment
TBF.mount
childrenLength ← childrenNodeLength
--button, div
TSA.shouldEqual 2 childrenLength
dispatchEvent clickEvent "#add-button"
initial ← textContent "#text-output-0"
TSA.shouldEqual "0" initial
dispatchEvent clickEvent "#decrement-button-0"
current ← textContent "#text-output-0"
TSA.shouldEqual "-1" current
dispatchEvent clickEvent "#add-button"
dispatchEvent clickEvent "#increment-button-1"
dispatchEvent clickEvent "#increment-button-1"
current2 ← textContent "#text-output-1"
TSA.shouldEqual "2" current2
TS.it "lazy" do
liftEffect do
unsafeCreateEnviroment
TFL.mount
childrenLength ← childrenNodeLength
--div
TSA.shouldEqual 1 childrenLength
dispatchEvent clickEvent "#add-button"
initial ← textContent "#add-button"
TSA.shouldEqual "Current Value: 1001" initial
dispatchEvent clickEvent "#add-button"
dispatchEvent clickEvent "#add-button"
current2 ← textContent "#add-button"
TSA.shouldEqual "Current Value: 3001" current2
TS.describe "Effectful specific" do
TS.it "slower effects" do
liftEffect do
unsafeCreateEnviroment
TES.mount
outputCurrent ← textContent "#text-output-current"
outputNumbers ← textContent "#text-output-numbers"
TSA.shouldEqual "0" outputCurrent
TSA.shouldEqual "[]" outputNumbers
--the event for snoc has a delay, make sure it doesnt overwrite unrelated fields when updating
dispatchEvent clickEvent "#snoc-button"
dispatchEvent clickEvent "#bump-button"
outputCurrent2 ← textContent "#text-output-current"
outputNumbers2 ← textContent "#text-output-numbers"
TSA.shouldEqual "1" outputCurrent2
TSA.shouldEqual "[]" outputNumbers2
AF.delay $ Milliseconds 1000.0
outputCurrent3 ← textContent "#text-output-current"
outputNumbers3 ← textContent "#text-output-numbers"
TSA.shouldEqual "2" outputCurrent3
TSA.shouldEqual "[0]" outputNumbers3
TS.describe "Subscription applications" do
TS.it "noeffects" do
liftEffect do
unsafeCreateEnviroment
TEN.mount
output ← textContent "#text-output"
TSA.shouldEqual "0" output
dispatchDocumentEvent clickEvent
output2 ← textContent "#text-output"
TSA.shouldEqual "-1" output2
dispatchDocumentEvent keydownEvent
dispatchDocumentEvent keydownEvent
dispatchDocumentEvent keydownEvent
output3 ← textContent "#text-output"
TSA.shouldEqual "2" output3
TS.it "effectlist" do
id ← liftEffect do
unsafeCreateEnviroment
TEEL.mount
output ← textContent "#text-output"
TSA.shouldEqual "0" output
liftEffect $ FS.send id TEELDecrement
output2 ← textContent "#text-output"
TSA.shouldEqual "-1" output2
liftEffect $ FS.send id TEELIncrement
output3 ← textContent "#text-output"
TSA.shouldEqual "0" output3
TS.it "effectful" do
liftEffect do
unsafeCreateEnviroment
TEE.mount
output ← textContent "#text-output"
TSA.shouldEqual "5" output
dispatchWindowEvent errorEvent
dispatchWindowEvent errorEvent
dispatchWindowEvent errorEvent
output2 ← textContent "#text-output"
TSA.shouldEqual "2" output2
dispatchWindowEvent offlineEvent
output3 ← textContent "#text-output"
TSA.shouldEqual "3" output3
TS.it "broadcast" do
id ← liftEffect do
unsafeCreateEnviroment
TSB.mount
output ← textContent "#text-output"
TSA.shouldEqual "0" output
liftEffect <<< FSUC.broadcast (EventType "decrement-event") $ Just 34
output2 ← textContent "#text-output"
TSA.shouldEqual "-34" output2
liftEffect $ FSUC.broadcast' (EventType "increment-event")
output3 ← textContent "#text-output"
TSA.shouldEqual "-33" output3
TS.describe "Server side rendering" do
TS.it "effectful" do
liftEffect do
unsafeCreateEnviroment
TSE.preMount
childrenLength ← childrenNodeLengthOf "#mount-point"
TSA.shouldEqual 1 childrenLength
childrenLength2 ← childrenNodeLengthOf "#my-id"
--before resuming mount there is an extra element with the serialized state
TSA.shouldEqual 4 childrenLength2
initial ← textContent "#text-output"
TSA.shouldEqual "2" initial
liftEffect TSE.mount
childrenLength3 ← childrenNodeLengthOf "#my-id"
TSA.shouldEqual 4 childrenLength3
initial2 ← textContent "#text-output"
TSA.shouldEqual "2" initial2
dispatchEvent clickEvent "#increment-button"
current ← textContent "#text-output"
TSA.shouldEqual "3" current
TS.it "managed nodes" do
liftEffect do
unsafeCreateEnviroment
TSM.preMount
childrenLength ← childrenNodeLengthOf "#mount-point"
TSA.shouldEqual 1 childrenLength
childrenLength2 ← childrenNodeLengthOf "#my-id"
TSA.shouldEqual 3 childrenLength2
--managed nodes are not rendered server-side
span ← liftEffect $ FAD.querySelector "#text-output"
TSA.shouldSatisfy span DM.isNothing
liftEffect TSM.mount
childrenLength3 ← childrenNodeLengthOf "#my-id"
TSA.shouldEqual 3 childrenLength3
initial2 ← textContent "#text-output"
TSA.shouldEqual "2" initial2
dispatchEvent clickEvent "#increment-button"
current ← textContent "#text-output"
TSA.shouldEqual "3" current
TS.it "fragment nodes" do
liftEffect do
unsafeCreateEnviroment
TSF.preMount
childrenLength ← childrenNodeLengthOf "#mount-point"
TSA.shouldEqual 1 childrenLength
childrenLength2 ← childrenNodeLengthOf "#my-id"
TSA.shouldEqual 4 childrenLength2
initial ← textContent "#text-output"
TSA.shouldEqual "2" initial
liftEffect TSF.mount
childrenLength3 ← childrenNodeLengthOf "#my-id"
TSA.shouldEqual 4 childrenLength3
initial2 ← textContent "#text-output"
TSA.shouldEqual "2" initial2
dispatchEvent clickEvent "#increment-button"
current ← textContent "#text-output"
TSA.shouldEqual "3" current
where
unsafeQuerySelector ∷ String → Effect Element
unsafeQuerySelector selector = do
maybeElement ← FAD.querySelector selector
case maybeElement of
Nothing → EEU.unsafeThrow $ "Selector not found! " <> selector
Just element → pure $ UC.unsafeCoerce element
mountHtml html = liftEffect do
unsafeCreateEnviroment
mountDiv ← unsafePartial (DM.fromJust <$> FAD.querySelector "#mount-point")
FRID.start mountDiv (const (pure unit)) html
mountHtml' html = liftEffect do
mountDiv ← unsafePartial (DM.fromJust <$> FAD.querySelector "#mount-point")
FRID.start mountDiv (const (pure unit)) html
getStyle selector = liftEffect do