diff options
author | bors-servo <release+servo@mozilla.com> | 2014-04-03 12:01:49 -0400 |
---|---|---|
committer | bors-servo <release+servo@mozilla.com> | 2014-04-03 12:01:49 -0400 |
commit | 897c679be28bbb29e248ca4c31ba917cf516e993 (patch) | |
tree | 61112774b3f202c64f48d1d4c5db78be73fe6d50 /src | |
parent | e3bf08ea537366a1624a082999c3548fa07d4650 (diff) | |
parent | faea1755059dded28bdaa11a156d7581f88ccc46 (diff) | |
download | servo-897c679be28bbb29e248ca4c31ba917cf516e993.tar.gz servo-897c679be28bbb29e248ca4c31ba917cf516e993.zip |
auto merge of #2031 : saneyuki/servo/2027, r=jdm
Fix #2027
@jdm
This change will decrease the generics for `Document::create_collection`.
Do you have any good idea to avoid this?
Or don't we have to consider it now?
Diffstat (limited to 'src')
-rw-r--r-- | src/components/script/dom/document.rs | 20 |
1 files 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<T>(&self, callback: |elem: &JS<Node>| -> Option<JS<T>>) -> ~[JS<T>] { - let mut nodes = ~[]; + pub fn createNodeList(&self, callback: |node: &JS<Node>| -> bool) -> JS<NodeList> { + let mut nodes: ~[JS<Node>] = ~[]; match self.GetDocumentElement() { None => {}, Some(root) => { let root: JS<Node> = 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<Node>| -> bool) -> JS<NodeList> { - 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) { |