Skip to content

Commit

Permalink
Skip the root node in querySelectorAll
Browse files Browse the repository at this point in the history
This accounts for whatwg/dom#263.
  • Loading branch information
nox committed Jul 4, 2016
1 parent 110fd68 commit 20df418
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
5 changes: 4 additions & 1 deletion components/script/dom/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,10 @@ impl Node {
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))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
[ParentNode-querySelector-All-xht.xht]
type: testharness
[Detached Element.querySelectorAll tree order]
expected: FAIL

[In-document Element.querySelectorAll tree order]
expected: FAIL

[Document.querySelectorAll: Attribute whitespace-separated list selector, not matching class attribute with empty value: #attr-whitespace [class~=""\]]
expected: FAIL

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
[ParentNode-querySelector-All.html]
type: testharness
[Detached Element.querySelectorAll tree order]
expected: FAIL

[In-document Element.querySelectorAll tree order]
expected: FAIL

[Document.querySelectorAll: Attribute whitespace-separated list selector, not matching class attribute with empty value: #attr-whitespace [class~=""\]]
expected: FAIL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
assert_equals(nodelist.length, 3);

nodelist = div.querySelectorAll("div:nth-of-type(1)");
assert_equals(nodelist.item(0), div);
assert_equals(nodelist.item(0), div.firstChild);
}, "Element");

test(function() {
Expand Down

0 comments on commit 20df418

Please sign in to comment.