WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
70879
:nth-child with descendant selector not selecting all elements
https://bugs.webkit.org/show_bug.cgi?id=70879
Summary
:nth-child with descendant selector not selecting all elements
pimvdb
Reported
2011-10-26 01:09:02 PDT
Created
attachment 112465
[details]
Test case Given the DOM as in the attached test case, the selector "td:nth-child(2) input" only selects the first input of each second td in each row, and not all four of them. This only happens with "document.querySelectorAll" in JavaScript; using this selector in CSS always works. "td:nth-child(1) input" returns all four expected elements.
Attachments
Test case
(852 bytes, text/html)
2011-10-26 01:09 PDT
,
pimvdb
no flags
Details
Test case with embedded script
(978 bytes, text/html)
2011-12-08 03:14 PST
,
Rod
no flags
Details
Test case with setTimeout
(1.29 KB, text/html)
2011-12-08 07:51 PST
,
pimvdb
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Rod
Comment 1
2011-12-08 03:14:02 PST
Created
attachment 118356
[details]
Test case with embedded script Script embedded in the new test case file also demonstrates the bug, only nth-child(1) works properly, the rest only find a single child element even though they should behave the same.
pimvdb
Comment 2
2011-12-08 07:51:56 PST
Created
attachment 118391
[details]
Test case with setTimeout The weird thing is - it does work when deferring the selector, i.e. with "setTimeout". Please see the attached test case - when executed immediately, the selector does not select correctly, but when using it in combination with "setTimeout", it does work.
samli
Comment 3
2012-01-04 19:45:24 PST
Confirmed with Google Chrome (17.0.963.26) Canary, Mac OS X Webkit 535.11 (@103967)
pimvdb
Comment 4
2012-01-05 05:12:19 PST
I'm testing this on Canary (18.0.997.0), but the "setTimeout" test case is working differently there. To get it work on Canary I have to open Developer Tools and select the "Elements" tab. Only after doing so and refreshing the page, executing "test()" produces 3-3-3 for the "setTimeout" (third) case. Without having Developer Tools open on the "Elements" tab, the result is 3-1-1 for the third case. Without "setTimeout" (the first two cases) the result is 3-1-1; this hasn't changed on Canary.
Brent Fulgham
Comment 5
2022-07-12 15:30:36 PDT
Safari, Chrome, and Firefox all agree on rendering for this test case. I don't believe there is any remaining compatibility issue.
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