Skip to content

Commit

Permalink
Add NodeList::item (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickycodes authored and koute committed Mar 26, 2018
1 parent 426b025 commit 927fe4a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/webapi/node_list.rs
Expand Up @@ -30,6 +30,16 @@ impl NodeList {
js!( return @{self}.length; ).try_into().unwrap()
}

/// Returns a node from a NodeList by index.
///
/// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/item)
// https://dom.spec.whatwg.org/#ref-for-dom-nodelist-item
pub fn item( &self, index: u32 ) -> Option< Node > {
js!(
return @{self}[ @{index} ];
).try_into().unwrap()
}

/// Returns an iterator over the list.
pub fn iter( &self ) -> NodeIter {
NodeIter {
Expand Down

0 comments on commit 927fe4a

Please sign in to comment.