New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 675670 link

Starred by 5 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Spec violation - <html> element not matching :first-child/etc

Project Member Reported by tabatkins@chromium.org, Dec 19 2016

Issue description

Chrome 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.
 

Comment 1 by tkent@chromium.org, Dec 19 2016

Components: Blink>CSS

Comment 2 by eco...@igalia.com, Dec 19 2016

Cc: eco...@igalia.com
Labels: -Pri-3 Pri-2
Status: Available (was: Untriaged)

Comment 4 by eco...@igalia.com, Dec 20 2016

Owner: eco...@igalia.com
Status: Started (was: Available)
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 :)
Please merge  issue 666655  into this one.

Comment 6 by eco...@igalia.com, Dec 20 2016

 Issue 666655  has been merged into this issue.
Labels: Hotlist-Interop

Comment 8 by eco...@igalia.com, Dec 21 2016

Oh, btw, CL (currently waiting on an intent to ship I need to write): https://codereview.chromium.org/2588643004/
\o/
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.
@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.
Project Member

Comment 14 by bugdroid1@chromium.org, 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

Comment 15 by r...@igalia.com, Jan 20 2017

Cc: r...@igalia.com
Status: Fixed (was: Started)

Sign in to add a comment