Spec violation - <html> element not matching :first-child/etc |
||||||
Issue descriptionChrome Version: 55.0.2883.44 (Official Build) beta (64-bit) OS: Gubuntu Per the most recent Selectors spec <https://drafts.csswg.org/selectors/#child-index> the :first-child, :nth-child(), and related pseudoclasses should apply to all elements, regardless of whether they have a parent or not. (:first-child is actually first-among-siblings, etc) We currently implement the old spec, which specified that those pseudo-classes did not match elements without a parent. (This was changed to make the pseudo-classes useful for top-level elements in a shadow tree. It would have been weird to carve out an exception just for shadow trees, and the compat impact of changing this for <html> was judged to be miniscule, so we made the change more generally.) Test case: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cstyle%3Ehtml%20%7B%20color%3A%20red%3B%20%7D%20html%3Afirst-child%20%7B%20color%3A%20green%3B%20%7D%3C%2Fstyle%3E%0Afoo Text should be green, but it's currently red.
,
Dec 19 2016
,
Dec 20 2016
,
Dec 20 2016
After taking a quick look, I'm taking this if it's fine, seems like a straight-forward change and I'm waiting for CQ runs for other stuff :)
,
Dec 20 2016
Please merge issue 666655 into this one.
,
Dec 20 2016
Issue 666655 has been merged into this issue.
,
Dec 20 2016
,
Dec 21 2016
Oh, btw, CL (currently waiting on an intent to ship I need to write): https://codereview.chromium.org/2588643004/
,
Dec 21 2016
\o/
,
Dec 21 2016
I'm pretty sure top level elements in a shadow tree have always matched these selectors, they don't have a null parent, the ShadowRoot is the parent. So the proposed change here is just for the documentElement? Note that that also has a parentNode, just not a parentElement. This issue isn't about not having a parent.
,
Dec 22 2016
@esprehn: The ShadowRoot is not an element, so per the technical definition the old "nth child of a parent element" definition didn't apply to the top-level children. We (browsers) matched them anyway because duh, but we (CSSWG) had to amend the spec to actually allow it, and the simplest amendment makes it apply to the root element too. We (CSSWG) considered this an acceptable change.
,
Jan 20 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/464e47a82e253d08a7c7236fcf5cb5ec5bf8660b commit 464e47a82e253d08a7c7236fcf5cb5ec5bf8660b Author: ecobos <ecobos@igalia.com> Date: Fri Jan 20 02:19:00 2017 Allow positional selectors to match elements without a parent. BUG= 675670 TEST=fast/selectors/child-indexed-pseudo-classes.html Review-Url: https://codereview.chromium.org/2588643004 Cr-Commit-Position: refs/heads/master@{#444956} [delete] https://crrev.com/8127a839bf18e618aaf7a8cad95440c6cd3f9f76/third_party/WebKit/LayoutTests/css3/selectors3/html/css3-modsel-27a.html [delete] https://crrev.com/8127a839bf18e618aaf7a8cad95440c6cd3f9f76/third_party/WebKit/LayoutTests/css3/selectors3/xhtml/css3-modsel-27a.xml [delete] https://crrev.com/8127a839bf18e618aaf7a8cad95440c6cd3f9f76/third_party/WebKit/LayoutTests/css3/selectors3/xml/css3-modsel-27a.css [delete] https://crrev.com/8127a839bf18e618aaf7a8cad95440c6cd3f9f76/third_party/WebKit/LayoutTests/css3/selectors3/xml/css3-modsel-27a.xml [modify] https://crrev.com/464e47a82e253d08a7c7236fcf5cb5ec5bf8660b/third_party/WebKit/LayoutTests/fast/css/first-letter-capitalized-edit-select-crash-expected.txt [add] https://crrev.com/464e47a82e253d08a7c7236fcf5cb5ec5bf8660b/third_party/WebKit/LayoutTests/fast/selectors/child-indexed-pseudo-classes.html [modify] https://crrev.com/464e47a82e253d08a7c7236fcf5cb5ec5bf8660b/third_party/WebKit/LayoutTests/http/tests/misc/acid3.html [modify] https://crrev.com/464e47a82e253d08a7c7236fcf5cb5ec5bf8660b/third_party/WebKit/Source/core/css/SelectorChecker.cpp [modify] https://crrev.com/464e47a82e253d08a7c7236fcf5cb5ec5bf8660b/third_party/WebKit/Source/core/dom/NthIndexCache.cpp
,
Jan 20 2017
|
||||||
►
Sign in to add a comment |
||||||
Comment 1 by tkent@chromium.org
, Dec 19 2016