{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.MutationEvent
(initMutationEvent, pattern MODIFICATION, pattern ADDITION,
pattern REMOVAL, getRelatedNode, getRelatedNodeUnsafe,
getRelatedNodeUnchecked, getPrevValue, getNewValue, getAttrName,
getAttrChange, MutationEvent(..), gTypeMutationEvent)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
initMutationEvent ::
(MonadDOM m, ToJSString type', IsNode relatedNode,
ToJSString prevValue, ToJSString newValue, ToJSString attrName) =>
MutationEvent ->
Maybe type' ->
Bool ->
Bool ->
Maybe relatedNode ->
Maybe prevValue ->
Maybe newValue -> Maybe attrName -> Maybe Word -> m ()
initMutationEvent self type' canBubble cancelable relatedNode
prevValue newValue attrName attrChange
= liftDOM
(void
(self ^. jsf "initMutationEvent"
[toJSVal type', toJSVal canBubble, toJSVal cancelable,
toJSVal relatedNode, toJSVal prevValue, toJSVal newValue,
toJSVal attrName, toJSVal attrChange]))
pattern MODIFICATION = 1
pattern ADDITION = 2
pattern REMOVAL = 3
getRelatedNode :: (MonadDOM m) => MutationEvent -> m (Maybe Node)
getRelatedNode self
= liftDOM ((self ^. js "relatedNode") >>= fromJSVal)
getRelatedNodeUnsafe ::
(MonadDOM m, HasCallStack) => MutationEvent -> m Node
getRelatedNodeUnsafe self
= liftDOM
(((self ^. js "relatedNode") >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return)
getRelatedNodeUnchecked :: (MonadDOM m) => MutationEvent -> m Node
getRelatedNodeUnchecked self
= liftDOM ((self ^. js "relatedNode") >>= fromJSValUnchecked)
getPrevValue ::
(MonadDOM m, FromJSString result) => MutationEvent -> m result
getPrevValue self
= liftDOM ((self ^. js "prevValue") >>= fromJSValUnchecked)
getNewValue ::
(MonadDOM m, FromJSString result) => MutationEvent -> m result
getNewValue self
= liftDOM ((self ^. js "newValue") >>= fromJSValUnchecked)
getAttrName ::
(MonadDOM m, FromJSString result) => MutationEvent -> m result
getAttrName self
= liftDOM ((self ^. js "attrName") >>= fromJSValUnchecked)
getAttrChange :: (MonadDOM m) => MutationEvent -> m Word
getAttrChange self
= liftDOM (round <$> ((self ^. js "attrChange") >>= valToNumber))