Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Web/DOM/NonElementParentNode.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,21 @@ foreign import data NonElementParentNode :: Type
-- | 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