Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 5d4aec0

Browse files
justinwoocryogenian
authored andcommitted
fix getElementById in examples Utils (#38)
1 parent 8c025ef commit 5d4aec0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
public/*.js
77
.psci_modules
88
.psci
9-
9+
.psc-ide-port

example/src/Utils.purs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Control.Monad.Except (runExcept)
1414

1515
import Data.Array ((!!), length)
1616
import Data.Int as Int
17-
import Data.Maybe (Maybe(..))
17+
import Data.Maybe (Maybe(..), fromJust)
1818
import Data.Either (either)
1919
import Data.Tuple (Tuple(..))
2020
import Data.Foreign (toForeign)
@@ -30,6 +30,7 @@ import DOM.Node.NonElementParentNode as NEPN
3030
import DOM.Node.Types (ElementId)
3131

3232
import Math (round, pow)
33+
import Partial.Unsafe (unsafePartial)
3334

3435
getElementById
3536
eff
@@ -39,7 +40,7 @@ getElementById elementId = do
3940
win ← window
4041
doc ← document win
4142
el ← NEPN.getElementById elementId (htmlDocumentToNonElementParentNode doc)
42-
pure $ either (const Nothing) Just $ runExcept $ readHTMLElement (toForeign el)
43+
pure $ either (const Nothing) Just $ runExcept $ readHTMLElement (toForeign <<< unsafePartial fromJust $ el)
4344

4445
onLoad
4546
eff a

0 commit comments

Comments
 (0)