Ticket #6364 (new defect)
[Element].querySelectorAll Does Not Work As You Expect It
| Reported by: | guest | Owned by: | anonymous |
|---|---|---|---|
| Priority: | normal | Milestone: | future |
| Component: | General | Version: | 1.1.0 |
| Severity: | normal | Keywords: | |
| Cc: | jresig@…, alex |
Description
In a follow-up to bug #5832: The querySelectorAll method doesn't behave as you expect it to when rooted against a DOM Element, observe the following example:
<div><p id="foo"><span></span></p></div>
<script src="http://o.aolcdn.com/dojo/1.1.0/dojo/dojo.xd.js"></script>
<script>
var foo = document.getElementById("foo");
alert( dojo.query('div span', foo).length ); // should return nothing
alert( foo.querySelectorAll('div span').length ); // will return the SPAN
</script>
You can view the demo here: http://ejohn.org/files/bugs/qsa-root/dojo.html
Note: The demo doesn't have any problems in Safari 3.1 because querySelectorAll is currently disabled by [13142] (but it will have problems in a future release of Safari - and in Internet Explorer 8b1).
I, personally, feel that this is a complete mistake in the specification and implementations of querySelectorAll - and should be rectified at the specification level. If you feel similarly please voice your concerns to the Web API Working Group, otherwise here's the bug for your future reference.