Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Documentation fixes for functions that now return Maybe #108

Merged
merged 1 commit into from
Jun 10, 2017
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/DOM/Node/HTMLCollection.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import DOM.Node.Types (Element, HTMLCollection, ElementId)
-- | The number of elements in a HTMLCollection.
foreign import length :: forall eff. HTMLCollection -> Eff (dom :: DOM | eff) Int

-- | The element in a HTMLCollection at the specified index, or null if no such
-- | The element in a HTMLCollection at the specified index, or Nothing if no such
-- | element exists.
item :: forall eff. Int -> HTMLCollection -> Eff (dom :: DOM | eff) (Maybe Element)
item i = map toMaybe <<< _item i

foreign import _item :: forall eff. Int -> HTMLCollection -> Eff (dom :: DOM | eff) (Nullable Element)

-- | The first element with the specified name or ID in a HTMLCollection, or
-- | null if no such element exists.
-- | Nothing if no such element exists.
namedItem :: forall eff. ElementId -> HTMLCollection -> Eff (dom :: DOM | eff) (Maybe Element)
namedItem id = map toMaybe <<< _namedItem id

Expand Down
10 changes: 5 additions & 5 deletions src/DOM/Node/Node.purs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ foreign import nodeName :: Node -> String
foreign import baseURI :: forall eff. Node -> Eff (dom :: DOM | eff) String

-- | The document the node belongs to, unless the node is a document in which
-- | case the value is null.
-- | case the value is Nothing.
ownerDocument :: forall eff. Node -> Eff (dom :: DOM | eff) (Maybe Document)
ownerDocument = map toMaybe <<< _ownerDocument

Expand All @@ -81,26 +81,26 @@ foreign import hasChildNodes :: forall eff. Node -> Eff (dom :: DOM | eff) Boole
-- | The children of the node.
foreign import childNodes :: forall eff. Node -> Eff (dom :: DOM | eff) NodeList

-- | The first child of the node, or null if the node has no children.
-- | The first child of the node, or Nothing if the node has no children.
firstChild :: forall eff. Node -> Eff (dom :: DOM | eff) (Maybe Node)
firstChild = map toMaybe <<< _firstChild

foreign import _firstChild :: forall eff. Node -> Eff (dom :: DOM | eff) (Nullable Node)


-- | The last child of the node, or null if the node has no children.
-- | The last child of the node, or Nothing if the node has no children.
lastChild :: forall eff. Node -> Eff (dom :: DOM | eff) (Maybe Node)
lastChild = map toMaybe <<< _lastChild

foreign import _lastChild :: forall eff. Node -> Eff (dom :: DOM | eff) (Nullable Node)

-- | The previous sibling node, or null if there is no previous sibling.
-- | The previous sibling node, or Nothing if there is no previous sibling.
previousSibling :: forall eff. Node -> Eff (dom :: DOM | eff) (Maybe Node)
previousSibling = map toMaybe <<< _previousSibling

foreign import _previousSibling :: forall eff. Node -> Eff (dom :: DOM | eff) (Nullable Node)

-- | The next sibling node, or null if there is no next sibling.
-- | The next sibling node, or Nothing if there is no next sibling.
nextSibling :: forall eff. Node -> Eff (dom :: DOM | eff) (Maybe Node)
nextSibling = map toMaybe <<< _nextSibling

Expand Down
2 changes: 1 addition & 1 deletion src/DOM/Node/NodeList.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DOM.Node.Types (Node, NodeList)
-- | The number of items in a NodeList.
foreign import length :: forall eff. NodeList -> Eff (dom :: DOM | eff) Int

-- | The item in a NodeList at the specified index, or null if no such node
-- | The item in a NodeList at the specified index, or Nothing if no such node
-- | exists.
item :: forall eff. Int -> NodeList -> Eff (dom :: DOM | eff) (Maybe Node)
item i = map toMaybe <<< _item i
Expand Down
4 changes: 2 additions & 2 deletions src/DOM/Node/NonDocumentTypeChildNode.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import Data.Nullable (Nullable, toMaybe)
import DOM (DOM)
import DOM.Node.Types (Element, NonDocumentTypeChildNode)

-- | The previous sibling that is an element, or null if no such element exists.
-- | The previous sibling that is an element, or Nothing if no such element exists.
previousElementSibling :: forall eff. NonDocumentTypeChildNode -> Eff (dom :: DOM | eff) (Maybe Element)
previousElementSibling = map toMaybe <<< _previousElementSibling

foreign import _previousElementSibling :: forall eff. NonDocumentTypeChildNode -> Eff (dom :: DOM | eff) (Nullable Element)

-- | The next sibling that is an element, or null if no such element exists.
-- | The next sibling that is an element, or Nothing if no such element exists.
nextElementSibling :: forall eff. NonDocumentTypeChildNode -> Eff (dom :: DOM | eff) (Maybe Element)
nextElementSibling = map toMaybe <<< _nextElementSibling

Expand Down
6 changes: 3 additions & 3 deletions src/DOM/Node/ParentNode.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import DOM.Node.Types (NodeList, ParentNode, Element, HTMLCollection)
-- | The child elements for the node.
foreign import children :: forall eff. ParentNode -> Eff (dom :: DOM | eff) HTMLCollection

-- | The first child that is an element, or null if no such element exists.
-- | The first child that is an element, or Nothing if no such element exists.
firstElementChild :: forall eff. ParentNode -> Eff (dom :: DOM | eff) (Maybe Element)
firstElementChild = map toMaybe <<< _firstElementChild

foreign import _firstElementChild :: forall eff. ParentNode -> Eff (dom :: DOM | eff) (Nullable Element)

-- | The last child that is an element, or null if no such element exists.
-- | The last child that is an element, or Nothing if no such element exists.
lastElementChild :: forall eff. ParentNode -> Eff (dom :: DOM | eff) (Maybe Element)
lastElementChild = map toMaybe <<< _lastElementChild

Expand All @@ -44,7 +44,7 @@ derive newtype instance ordQuerySelector :: Ord QuerySelector
derive instance newtypeQuerySelector :: Newtype QuerySelector _

-- | Finds the first child that is an element that matches the selector(s), or
-- | null if no such element exists.
-- | Nothing if no such element exists.
querySelector :: forall eff. QuerySelector -> ParentNode -> Eff (dom :: DOM | eff) (Maybe Element)
querySelector qs = map toMaybe <<< _querySelector qs

Expand Down