packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/HTMLOptionsCollection.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from html (webref). Do not edit.
module JSDOM.Generated.HTMLOptionsCollection
       (add, remove, setLength, getLength, setSelectedIndex, getSelectedIndex, HTMLOptionsCollection(..), gTypeHTMLOptionsCollection)
       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/HTMLOptionsCollection/add MDN HTMLOptionsCollection.add documentation>
add :: (MonadDOM m, IsHTMLOptionElementOrHTMLOptGroupElement element, IsHTMLElementOrInt before) => HTMLOptionsCollection -> element -> Maybe before -> m ()
add self element before = liftDOM (void (self ^. jsf "add" [toJSVal element, toJSVal before]))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLOptionsCollection/remove MDN HTMLOptionsCollection.remove documentation>
remove :: (MonadDOM m) => HTMLOptionsCollection -> Int -> m ()
remove self index = liftDOM (void (self ^. jsf "remove" [toJSVal index]))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLOptionsCollection/length MDN HTMLOptionsCollection.length documentation>
setLength :: (MonadDOM m) => HTMLOptionsCollection -> Word -> m ()
setLength self val = liftDOM (void (self ^. jss "length" (toJSVal val)))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLOptionsCollection/length MDN HTMLOptionsCollection.length documentation>
getLength :: (MonadDOM m) => HTMLOptionsCollection -> m Word
getLength self = liftDOM ((P.round <$> ((self ^. js "length") >>= valToNumber)))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLOptionsCollection/selectedIndex MDN HTMLOptionsCollection.selectedIndex documentation>
setSelectedIndex :: (MonadDOM m) => HTMLOptionsCollection -> Int -> m ()
setSelectedIndex self val = liftDOM (void (self ^. jss "selectedIndex" (toJSVal val)))

-- | <https://developer.mozilla.org/docs/Web/API/HTMLOptionsCollection/selectedIndex MDN HTMLOptionsCollection.selectedIndex documentation>
getSelectedIndex :: (MonadDOM m) => HTMLOptionsCollection -> m Int
getSelectedIndex self = liftDOM ((P.round <$> ((self ^. js "selectedIndex") >>= valToNumber)))