:last-of-type not working for children of body in JS
Reported by
chrisbru...@gmail.com,
Nov 3 2016
|
|||||
Issue description
Chrome Version : 54.0.2840.71 (Official Build) (64-bit)
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL, along with the version, after other browsers where you
have tested this issue:
Safari:
Firefox: OK 47.0.1
IE: 11
What steps will reproduce the problem?
(1) Create a new HTML document with 3 SECTION elements within the BODY
(2) Attempt to use document.querySelector('section:last-of-type') to select the last section
What is the expected result?
Should return the last section
What happens instead?
Returns undefined
Please provide any additional information below. Attach a screenshot if
possible.
If nested in another element (such as a MAIN) then the selector works as expected
,
Nov 7 2016
Example attached. If you simply wrap the 3 paragraph elements in a <section> then the selector then works as expected. This is Windows 10 and OSX (El Capitan) Works in IE and Firefox Fails in Chrome and Safari
,
Nov 9 2016
,
Nov 15 2016
,
Nov 15 2016
,
Nov 15 2016
,
Nov 16 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/2b2e6f1d8ded02c97fbdda7088e24f84ad035ea3 commit 2b2e6f1d8ded02c97fbdda7088e24f84ad035ea3 Author: rune <rune@opera.com> Date: Wed Nov 16 15:22:26 2016 Let querySelector(All) match (nth-)last with unclosed parent. While parsing, we don't match :last*, :nth-last* etc until we finish parsing children to avoid alternating between different computed styles during loading. For querying selectors, however, we should. I couldn't find this explicitly mentioned in w3c or whatwg specs for querySelector(All), but Firefox and IE does this. This could happen if you have: <body> <p></p> <p></p> <script>document.querySelector("p:last-of-type")</script> </body> Adding expectations file for a wpt which now fails. The modifications to the test has been upstreamed to the github repo. See PR [1]. [1] https://github.com/w3c/web-platform-tests/pull/4216 R=sashab@chromium.org BUG= 662036 Review-Url: https://codereview.chromium.org/2505543004 Cr-Commit-Position: refs/heads/master@{#432493} [add] https://crrev.com/2b2e6f1d8ded02c97fbdda7088e24f84ad035ea3/third_party/WebKit/LayoutTests/imported/wpt/shadow-dom/untriaged/shadow-trees/upper-boundary-encapsulation/test-009-expected.txt [modify] https://crrev.com/2b2e6f1d8ded02c97fbdda7088e24f84ad035ea3/third_party/WebKit/Source/core/css/SelectorChecker.cpp [modify] https://crrev.com/2b2e6f1d8ded02c97fbdda7088e24f84ad035ea3/third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp
,
Nov 16 2016
,
Nov 17 2016
:first-child doesn't match the html element in Chrome, is this a bug?
,
Nov 17 2016
The html element is the root element of a document and so not a child of anything. Therefore I don't believe that behaviour to be a bug...
,
Nov 17 2016
Comment #10 is correct.
,
Nov 18 2016
Re #10 #11, seems like this has changed in selectors level 4, I raised a issue 666655 . |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by hdodda@chromium.org
, Nov 4 2016Labels: Needs-Feedback