packages feed

ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/HTMLAllCollection.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from html (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.HTMLAllCollection
       (js_item, js_namedItem, js_getLength, item, item_, itemUnsafe, itemUnchecked, namedItem, namedItem_, namedItemUnsafe, namedItemUnchecked, getLength, HTMLAllCollection(..), gTypeHTMLAllCollection)
       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 :: HTMLAllCollection -> (Optional JSString) -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/item MDN HTMLAllCollection.item documentation>
item :: (MonadDOM m, ToJSString nameOrIndex) => HTMLAllCollection -> Maybe nameOrIndex -> m (Maybe HTMLCollectionOrElement)
item self nameOrIndex = liftDOM (((js_item (self) (toOptionalJSString nameOrIndex)) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/item MDN HTMLAllCollection.item documentation>
item_ :: (MonadDOM m, ToJSString nameOrIndex) => HTMLAllCollection -> Maybe nameOrIndex -> m ()
item_ self nameOrIndex = liftDOM (void ((js_item (self) (toOptionalJSString nameOrIndex))))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/item MDN HTMLAllCollection.item documentation>
itemUnsafe :: (MonadDOM m, ToJSString nameOrIndex, HasCallStack) => HTMLAllCollection -> Maybe nameOrIndex -> m HTMLCollectionOrElement
itemUnsafe self nameOrIndex = liftDOM ((((js_item (self) (toOptionalJSString nameOrIndex)) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/item MDN HTMLAllCollection.item documentation>
itemUnchecked :: (MonadDOM m, ToJSString nameOrIndex) => HTMLAllCollection -> Maybe nameOrIndex -> m HTMLCollectionOrElement
itemUnchecked self nameOrIndex = liftDOM ((pFromJSVal <$> (js_item (self) (toOptionalJSString nameOrIndex))))

foreign import javascript safe "(($1, $2) => { return $1[\"namedItem\"]($2); })"
        js_namedItem :: HTMLAllCollection -> JSString -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/namedItem MDN HTMLAllCollection.namedItem documentation>
namedItem :: (MonadDOM m, ToJSString name) => HTMLAllCollection -> name -> m (Maybe HTMLCollectionOrElement)
namedItem self name = liftDOM (((js_namedItem (self) (toJSString name)) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/namedItem MDN HTMLAllCollection.namedItem documentation>
namedItem_ :: (MonadDOM m, ToJSString name) => HTMLAllCollection -> name -> m ()
namedItem_ self name = liftDOM (void ((js_namedItem (self) (toJSString name))))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/namedItem MDN HTMLAllCollection.namedItem documentation>
namedItemUnsafe :: (MonadDOM m, ToJSString name, HasCallStack) => HTMLAllCollection -> name -> m HTMLCollectionOrElement
namedItemUnsafe self name = liftDOM ((((js_namedItem (self) (toJSString name)) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/namedItem MDN HTMLAllCollection.namedItem documentation>
namedItemUnchecked :: (MonadDOM m, ToJSString name) => HTMLAllCollection -> name -> m HTMLCollectionOrElement
namedItemUnchecked self name = liftDOM ((pFromJSVal <$> (js_namedItem (self) (toJSString name))))

foreign import javascript unsafe "(($1) => { return $1[\"length\"]; })"
        js_getLength :: HTMLAllCollection -> IO Word
-- | <https://developer.mozilla.org/docs/Web/API/HTMLAllCollection/length MDN HTMLAllCollection.length documentation>
getLength :: (MonadDOM m) => HTMLAllCollection -> m Word
getLength self = liftDOM ((js_getLength (self)))