|
| 1 | +module DOM.Node.MutationRecord |
| 2 | + ( MutationRecord |
| 3 | + , MutationRecordType(..) |
| 4 | + , typeString |
| 5 | + , type_ |
| 6 | + , target |
| 7 | + , addedNodes |
| 8 | + , removedNodes |
| 9 | + , nextSibling |
| 10 | + , previousSibling |
| 11 | + , attributeName |
| 12 | + , attributeNamespace |
| 13 | + , oldValue |
| 14 | + ) where |
| 15 | + |
| 16 | +import Prelude |
| 17 | + |
| 18 | +import Control.Monad.Eff (Eff) |
| 19 | +import DOM (DOM) |
| 20 | +import DOM.Node.Types (Node, NodeList) |
| 21 | +import Data.Maybe (Maybe) |
| 22 | +import Data.Nullable (Nullable, toMaybe) |
| 23 | + |
| 24 | +foreign import data MutationRecord :: Type |
| 25 | + |
| 26 | +data MutationRecordType |
| 27 | + = MutationRecordAttributes |
| 28 | + | MutationRecordCharacterData |
| 29 | + | MutationRecordChildList |
| 30 | + |
| 31 | +foreign import typeString :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) String |
| 32 | + |
| 33 | +type_ :: forall eff. Partial => MutationRecord -> Eff (dom :: DOM | eff) MutationRecordType |
| 34 | +type_ = map stringToType <<< typeString |
| 35 | + where |
| 36 | + stringToType = case _ of |
| 37 | + "attributes" -> MutationRecordAttributes |
| 38 | + "characterData" -> MutationRecordCharacterData |
| 39 | + "childList" -> MutationRecordChildList |
| 40 | + |
| 41 | +foreign import target :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) Node |
| 42 | + |
| 43 | +foreign import addedNodes :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) NodeList |
| 44 | + |
| 45 | +foreign import removedNodes :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) NodeList |
| 46 | + |
| 47 | +foreign import _nextSibling :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Nullable Node) |
| 48 | + |
| 49 | +nextSibling :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Maybe Node) |
| 50 | +nextSibling = map toMaybe <<< _nextSibling |
| 51 | + |
| 52 | +foreign import _previousSibling :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Nullable Node) |
| 53 | + |
| 54 | +previousSibling :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Maybe Node) |
| 55 | +previousSibling = map toMaybe <<< _previousSibling |
| 56 | + |
| 57 | +foreign import _attributeName :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Nullable String) |
| 58 | + |
| 59 | +attributeName :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Maybe String) |
| 60 | +attributeName = map toMaybe <<< _attributeName |
| 61 | + |
| 62 | +foreign import _attributeNamespace :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Nullable String) |
| 63 | + |
| 64 | +attributeNamespace :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Maybe String) |
| 65 | +attributeNamespace = map toMaybe <<< _attributeNamespace |
| 66 | + |
| 67 | +foreign import _oldValue :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Nullable String) |
| 68 | + |
| 69 | +oldValue :: forall eff. MutationRecord -> Eff (dom :: DOM | eff) (Maybe String) |
| 70 | +oldValue = map toMaybe <<< _oldValue |
0 commit comments