From d03675f9effa443811f054578f7c24e17adbd6dc Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 28 Jan 2025 11:41:22 -0500 Subject: Fix missing panel situation --- src/Utils.purs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/Utils.purs') 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 -- cgit v1.2.3