jsaddle-dom-0.10.0.0: src/JSDOM/Generated/HTMLCollection.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from dom (webref). Do not edit.
module JSDOM.Generated.HTMLCollection
(item, item_, itemUnsafe, itemUnchecked, namedItem, namedItem_, namedItemUnsafe, namedItemUnchecked, getLength, HTMLCollection(..), gTypeHTMLCollection, IsHTMLCollection, toHTMLCollection)
where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/item MDN HTMLCollection.item documentation>
item :: (MonadDOM m, IsHTMLCollection self) => self -> Word -> m (Maybe Element)
item self index = liftDOM ((((Types.toHTMLCollection self) ^. jsf "item" [toJSVal index]) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/item MDN HTMLCollection.item documentation>
item_ :: (MonadDOM m, IsHTMLCollection self) => self -> Word -> m ()
item_ self index = liftDOM (void ((Types.toHTMLCollection self) ^. jsf "item" [toJSVal index]))
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/item MDN HTMLCollection.item documentation>
itemUnsafe :: (MonadDOM m, IsHTMLCollection self, HasCallStack) => self -> Word -> m Element
itemUnsafe self index = liftDOM (((((Types.toHTMLCollection self) ^. jsf "item" [toJSVal index]) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/item MDN HTMLCollection.item documentation>
itemUnchecked :: (MonadDOM m, IsHTMLCollection self) => self -> Word -> m Element
itemUnchecked self index = liftDOM ((((Types.toHTMLCollection self) ^. jsf "item" [toJSVal index]) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/namedItem MDN HTMLCollection.namedItem documentation>
namedItem :: (MonadDOM m, IsHTMLCollection self, ToJSString name) => self -> name -> m (Maybe Element)
namedItem self name = liftDOM ((((Types.toHTMLCollection self) ^. jsf "namedItem" [toJSVal name]) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/namedItem MDN HTMLCollection.namedItem documentation>
namedItem_ :: (MonadDOM m, IsHTMLCollection self, ToJSString name) => self -> name -> m ()
namedItem_ self name = liftDOM (void ((Types.toHTMLCollection self) ^. jsf "namedItem" [toJSVal name]))
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/namedItem MDN HTMLCollection.namedItem documentation>
namedItemUnsafe :: (MonadDOM m, IsHTMLCollection self, ToJSString name, HasCallStack) => self -> name -> m Element
namedItemUnsafe self name = liftDOM (((((Types.toHTMLCollection self) ^. jsf "namedItem" [toJSVal name]) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/namedItem MDN HTMLCollection.namedItem documentation>
namedItemUnchecked :: (MonadDOM m, IsHTMLCollection self, ToJSString name) => self -> name -> m Element
namedItemUnchecked self name = liftDOM ((((Types.toHTMLCollection self) ^. jsf "namedItem" [toJSVal name]) >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/length MDN HTMLCollection.length documentation>
getLength :: (MonadDOM m, IsHTMLCollection self) => self -> m Word
getLength self = liftDOM ((P.round <$> (((Types.toHTMLCollection self) ^. js "length") >>= valToNumber)))