packages feed

ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/NodeList.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.NodeList
       (js_item, js_getLength, item, item_, itemUnsafe, itemUnchecked, getLength, NodeList(..), gTypeNodeList, IsNodeList, toNodeList)
       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 :: NodeList -> Word -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/NodeList/item MDN NodeList.item documentation>
item :: (MonadDOM m, IsNodeList self) => self -> Word -> m (Maybe Node)
item self index = liftDOM (((js_item ((Types.toNodeList self)) (index)) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/NodeList/item MDN NodeList.item documentation>
item_ :: (MonadDOM m, IsNodeList self) => self -> Word -> m ()
item_ self index = liftDOM (void ((js_item ((Types.toNodeList self)) (index))))

-- | <https://developer.mozilla.org/docs/Web/API/NodeList/item MDN NodeList.item documentation>
itemUnsafe :: (MonadDOM m, IsNodeList self, HasCallStack) => self -> Word -> m Node
itemUnsafe self index = liftDOM ((((js_item ((Types.toNodeList self)) (index)) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/NodeList/item MDN NodeList.item documentation>
itemUnchecked :: (MonadDOM m, IsNodeList self) => self -> Word -> m Node
itemUnchecked self index = liftDOM ((pFromJSVal <$> (js_item ((Types.toNodeList self)) (index))))

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