WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
17461
querySelectorAll doesn't return correct nodes when using element in element patterns
https://bugs.webkit.org/show_bug.cgi?id=17461
Summary
querySelectorAll doesn't return correct nodes when using element in element p...
Moxiecode Systems
Reported
2008-02-20 15:38:27 PST
When using the querySelectorAll method on an element it doesn't return the correct number of nodes if a pattern with elements in elements are used. For example if this code is executed on an element with 4 divs but only one div withing another div it should return 1 and not 4. document.getElementById('test').querySelectorAll('div div'); HTML: <div id="test"> <div>1</div> <div> <div>2</div> </div> <div>3</div> </div>
Attachments
Testcase to illustrate the bug.
(208 bytes, text/html)
2008-02-20 15:40 PST
,
Moxiecode Systems
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Moxiecode Systems
Comment 1
2008-02-20 15:40:28 PST
Created
attachment 19242
[details]
Testcase to illustrate the bug. This test case will alert 4 but should alert 1 since only one div is inside another div.
Anne van Kesteren
Comment 2
2008-02-20 15:53:18 PST
I'd mark this INVALID, but can't. Anyway, selectors are always matched agains the document element. However, for calls on element nodes all nodes not part of the sub tree of that element node are filtered out. This is why you end up with 4 and not 1 or 5.
Anne van Kesteren
Comment 3
2008-02-20 15:56:13 PST
I shouild have mentioned that we will clarify the specification in due course to make this more explicit.
Adam Roben (:aroben)
Comment 4
2008-02-20 15:56:49 PST
Marking INVALID per Anne's comments.
Moxiecode Systems
Comment 5
2008-02-20 16:00:42 PST
Hmm, strange since this is not the way common libraries like jQuery/Prototype etc work. They all return 1 if you scope the search to an specific element so this can't be used as an replacement for those APIs. I could not find anything about this in the W3C specification so I'm wondering what is the correct behavior?
Sam Weinig
Comment 6
2008-03-09 08:14:31 PDT
***
Bug 17731
has been marked as a duplicate of this bug. ***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug