From faea1755059dded28bdaa11a156d7581f88ccc46 Mon Sep 17 00:00:00 2001 From: Tetsuharu OHZEKI Date: Thu, 3 Apr 2014 16:17:45 +0900 Subject: [PATCH] Document::create_collection's callback should return a boolean instead of a node. (#2027) --- src/components/script/dom/document.rs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) 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) {