ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/HTMLCollection.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from dom (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.HTMLCollection
(js_item, js_namedItem, js_getLength, 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 GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import GHCJS.DOM.Types
import qualified GHCJS.DOM.Types as Types
import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import GHCJS.DOM.JSFFI.Generated.Enums
foreign import javascript safe "(($1, $2) => { return $1[\"item\"]($2); })"
js_item :: HTMLCollection -> Word -> IO JSVal
-- | <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 (((js_item ((Types.toHTMLCollection self)) (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 ((js_item ((Types.toHTMLCollection self)) (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 ((((js_item ((Types.toHTMLCollection self)) (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 ((pFromJSVal <$> (js_item ((Types.toHTMLCollection self)) (index))))
foreign import javascript safe "(($1, $2) => { return $1[\"namedItem\"]($2); })"
js_namedItem :: HTMLCollection -> JSString -> IO JSVal
-- | <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 (((js_namedItem ((Types.toHTMLCollection self)) (toJSString 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 ((js_namedItem ((Types.toHTMLCollection self)) (toJSString 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 ((((js_namedItem ((Types.toHTMLCollection self)) (toJSString 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 ((pFromJSVal <$> (js_namedItem ((Types.toHTMLCollection self)) (toJSString name))))
foreign import javascript unsafe "(($1) => { return $1[\"length\"]; })"
js_getLength :: HTMLCollection -> IO Word
-- | <https://developer.mozilla.org/docs/Web/API/HTMLCollection/length MDN HTMLCollection.length documentation>
getLength :: (MonadDOM m, IsHTMLCollection self) => self -> m Word
getLength self = liftDOM ((js_getLength ((Types.toHTMLCollection self))))