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

Commit 63045ac

Browse files
authored
Merge pull request #117 from i-am-tom/master
Add `toArray` to NodeList
2 parents 6da1fd5 + d6e672a commit 63045ac

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/DOM/Node/NodeList.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ exports.length = function (list) {
66
};
77
};
88

9+
exports.toArray = function (list) {
10+
return function () {
11+
return [].slice.call(list);
12+
};
13+
};
14+
915
exports._item = function (index) {
1016
return function (list) {
1117
return function () {

src/DOM/Node/NodeList.purs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module DOM.Node.NodeList
22
( length
33
, item
4+
, toArray
45
) where
56

67
import Prelude
@@ -13,6 +14,9 @@ import DOM.Node.Types (Node, NodeList)
1314
-- | The number of items in a NodeList.
1415
foreign import length :: forall eff. NodeList -> Eff (dom :: DOM | eff) Int
1516

17+
-- | The elements of a NodeList represented in an array.
18+
foreign import toArray :: forall eff. NodeList -> Eff (dom :: DOM | eff) (Array Node)
19+
1620
-- | The item in a NodeList at the specified index, or Nothing if no such node
1721
-- | exists.
1822
item :: forall eff. Int -> NodeList -> Eff (dom :: DOM | eff) (Maybe Node)

0 commit comments

Comments
 (0)