Refactor code for fetching radio siblings

This commit is contained in:
Manish Goregaokar 2014-11-24 12:16:09 +05:30
parent 14a6e54371
commit a5180a473d
2 changed files with 50 additions and 22 deletions

View file

@ -81,3 +81,17 @@ impl Reflectable for NodeList {
&self.reflector_
}
}
pub trait NodeListHelpers {
fn into_vec(self) -> Vec<Temporary<Node>>;
}
impl<'a> NodeListHelpers for JSRef<'a, NodeList> {
fn into_vec(self) -> Vec<Temporary<Node>> {
match self.list_type {
Simple(ref elems) => elems.iter().map(|j| Temporary::new(*j)).collect(),
Children(ref node) => vec![Temporary::new(*node)]
}
}
}