diff options
| author | LLLL Colonq <llll@colonq> | 2025-01-28 11:41:22 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-01-28 11:41:38 -0500 |
| commit | d03675f9effa443811f054578f7c24e17adbd6dc (patch) | |
| tree | e4b2b9d90d80576f84bda290ce3145a7525be3cd /src/Utils.purs | |
| parent | 91e2134e6ccfa0536314248545c88db01c1dc711 (diff) | |
Fix missing panel situation
Diffstat (limited to 'src/Utils.purs')
| -rw-r--r-- | src/Utils.purs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Utils.purs b/src/Utils.purs index 8c530ef..e4fd125 100644 --- a/src/Utils.purs +++ b/src/Utils.purs @@ -32,11 +32,15 @@ maybeToArray :: forall a. Maybe a -> Array a maybeToArray (Just x) = [x] maybeToArray Nothing = [] -byId :: forall m. MonadEffect m => String -> m DOM.Element -byId i = do +maybeById :: forall m. MonadEffect m => String -> m (Maybe DOM.Element) +maybeById i = do w <- liftEffect HTML.window d <- liftEffect $ HTML.Doc.toDocument <$> HTML.Win.document w - liftEffect (DOM.NEP.getElementById i (DOM.Doc.toNonElementParentNode d)) >>= case _ of + liftEffect (DOM.NEP.getElementById i (DOM.Doc.toNonElementParentNode d)) + +byId :: forall m. MonadEffect m => String -> m DOM.Element +byId i = do + maybeById i >>= case _ of Nothing -> liftEffect $ throw $ "could not find element with id: " <> i Just e -> pure e |
