NodeList
NodeList objects are collections of nodes, usually returned by properties such as Node.childNodes and methods such as document.querySelectorAll().
Properties
isEmpty | ||
| Returns true if the NodeList contains no nodes, false otherwise. | ||
Methods
item(index: number )
Returns the node at the specified index in the NodeList.
| Name | Type | Description |
|---|---|---|
| index | The zero-based index of the node to retrieve |
forEach(looper: function )
Executes a function for each node in the NodeList.
| Name | Type | Description |
|---|---|---|
| looper | The function to execute for each node. Receives the node as its argument. |
plus(nodes: NodeList )
Returns a new NodeList containing all nodes from this list plus the nodes from another NodeList. The original NodeLists are not modified.
| Name | Type | Description |
|---|---|---|
| nodes | The NodeList to combine with this one |
appending(nodes: NodeList )
Returns a new NodeList with the specified nodes appended to the end of this list. The original NodeList is not modified.
| Name | Type | Description |
|---|---|---|
| nodes | The NodeList to append to this one |
prepending(nodes: NodeList )
Returns a new NodeList with the specified nodes prepended to the beginning of this list. The original NodeList is not modified.
| Name | Type | Description |
|---|---|---|
| nodes | The NodeList to prepend to this one |
filter(predicate: function | string )
Returns a new NodeList containing only the nodes that pass the test implemented by the predicate function. The original NodeList is not modified.
| Name | Type | Description |
|---|---|---|
| predicate | A function that tests each node, or a CSS selector string |
toArray()
Returns a new Array containing the nodes in the NodeList.
Returnsmap(mapper: function )
Returns a new Array containing the results of applying the mapper function to each node in the NodeList.
| Name | Type | Description |
|---|---|---|
| mapper | A function that transforms each node into a new value |
apply(mapper: function )
Applies the mapper function to each node in the NodeList, with each node as the 'this' context. The original NodeList is returned for chaining.
| Name | Type | Description |
|---|---|---|
| mapper | A function to apply to each node |
reduce(accumulator: function , initialValue: * )
Reduces the NodeList to a single value by applying an accumulator function to each node. The accumulator function receives the previous result and the current node.
| Name | Type | Description |
|---|---|---|
| accumulator | A function that combines the previous result with the current node | |
| initialValue | The initial value to start the reduction with |
last()
Returns the last node in the NodeList, or null if the list is empty.
Returnsfirst(count?: number )
Returns the first node (no arg) or the first count nodes as a
NodeList (ADR-215 W1-G).
| Name | Type | Description |
|---|---|---|
| count Optional |
topMost(count: number )
Returns a new StaticNodeList with the last count nodes (the
top of a pile). ADR-215 W1-G canonical name for this.
| Name | Type | Description |
|---|---|---|
| count |
take(count: number )
| Name | Type | Description |
|---|---|---|
| count |

