-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathNonElementParentNode.purs
More file actions
36 lines (31 loc) · 1.25 KB
/
NonElementParentNode.purs
File metadata and controls
36 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Web.DOM.NonElementParentNode
( NonElementParentNode
, getElementById
) where
import Prelude
import Data.Maybe (Maybe)
import Data.Nullable (Nullable, toMaybe)
import Effect (Effect)
import Web.DOM.Element (Element)
foreign import data NonElementParentNode :: Type
-- | The first element within node's descendants with a matching ID, or null if
-- | no such element exists.
foreign import _getElementById :: String -> NonElementParentNode -> Effect (Nullable Element)
-- | The first element within a node’s descendants with a matching ID, or `null` if
-- | no such element exists.
-- |
-- | This example shows how to call `getElementById` to get the `"root"` element
-- | of an HTML5 DOM.
-- |
-- | ```purescript
-- | import Web.HTML (window) -- from purescript-web-html
-- | import Web.HTML.Window (document) -- from purescript-web-html
-- | import Web.HTML.HTMLDocument (toDocument) -- from purescript-web-html
-- | import Web.DOM.Document (toNonElementParentNode)
-- |
-- | do
-- | n <- map toNonElementParentNode $ map toDocument $ document =<< window
-- | e <- getElementById "root" n
-- | ```
getElementById :: String -> NonElementParentNode -> Effect (Maybe Element)
getElementById eid = map toMaybe <<< _getElementById eid