diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 24767aaec52..f2cfa57d136 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -563,31 +563,21 @@ impl Document { HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), filter) } - pub fn create_collection(&self, callback: |elem: &JS| -> Option>) -> ~[JS] { - let mut nodes = ~[]; + pub fn createNodeList(&self, callback: |node: &JS| -> bool) -> JS { + let mut nodes: ~[JS] = ~[]; match self.GetDocumentElement() { None => {}, Some(root) => { let root: JS = NodeCast::from(&root); for child in root.traverse_preorder() { - match callback(&child) { - Some(node) => nodes.push(node), - None => (), + if callback(&child) { + nodes.push(child.clone()); } } } } - nodes - } - pub fn createNodeList(&self, callback: |node: &JS| -> bool) -> JS { - NodeList::new_simple_list(&self.window, self.create_collection(|node| { - if !callback(node) { - return None; - } - - Some(node.clone()) - })) + NodeList::new_simple_list(&self.window, nodes) } pub fn content_changed(&self) {