servo: Merge #12214 - Skip the root node in querySelectorAll (from nox:queryselector); r=Ms2ger
authorAnthony Ramine <n.oxyde@gmail.com>
Mon, 04 Jul 2016 05:53:14 -0700
changeset 339197 cf42313bd3642a28ce57084dd9789072dd8abcd0
parent 339196 dc371b7acd948cb0864bf03b94c70189bec4f8c7
child 339198 0efca26cdbe9c0e4749ce2be2b21de398cacd8fb
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
servo: Merge #12214 - Skip the root node in querySelectorAll (from nox:queryselector); r=Ms2ger Source-Repo: https://github.com/servo/servo Source-Revision: 3c51290f9e3bb5a1b4118671f24fba219abeabc8
servo/components/script/dom/node.rs
--- a/servo/components/script/dom/node.rs
+++ b/servo/components/script/dom/node.rs
@@ -735,17 +735,20 @@ impl Node {
     pub fn query_selector_iter(&self, selectors: DOMString)
                                   -> Fallible<QuerySelectorIterator> {
         // Step 1.
         match parse_author_origin_selector_list_from_str(&selectors) {
             // Step 2.
             Err(()) => Err(Error::Syntax),
             // Step 3.
             Ok(selectors) => {
-                Ok(QuerySelectorIterator::new(self.traverse_preorder(), selectors))
+                let mut descendants = self.traverse_preorder();
+                // Skip the root of the tree.
+                assert!(&*descendants.next().unwrap() == self);
+                Ok(QuerySelectorIterator::new(descendants, selectors))
             }
         }
     }
 
     // https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
     #[allow(unsafe_code)]
     pub fn query_selector_all(&self, selectors: DOMString) -> Fallible<Root<NodeList>> {
         let window = window_from_node(self);