W3C home > Mailing lists > Public > public-css-archive@w3.org > April 2019

[csswg-drafts] [selectors-4] Need to allow stacked pseudo-element selectors in the grammar (#3876)

From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
Date: Thu, 25 Apr 2019 21:49:04 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-437412277-1556228943-sysbot+gh@w3.org>
tabatkins has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors-4] Need to allow stacked pseudo-element selectors in the grammar ==
In Lists, we've resolved that ::before and ::after can be set to "display: list-item", thus generating markers. However, [per Selectors grammar](https://drafts.csswg.org/selectors/#typedef-compound-selector), it's not valid to then write a selector like `ol::before::marker`. (You can stack pseudo-*classes* after your pseudo-element, but not more pseudo-elements.)

This seems unfortunate; if a ::before can *generate* a marker, you should be able to *style* that marker.

Additionally, I know that WebKit-derived browsers, at least, *do* allow pseudo-element stacking, to handle styling some of the UA-specific pseudo-elements.

So, we should change Selectors grammar to allow stacking multiple pseudo-elements in a single compound selector. (Individual grammar restrictions will still restrict what sort of stacks are valid; `::before::before` will be an invalid selector, just like `::before:invalid` is invalid today even tho `::before:hover` is valid.)

Since certain pseudo-classes are reasonable to apply to either of the pseudo-elements in the stack, the two need to be arbitrary interleavable. (For example, `::before:hover::marker`.) This gives us a grammar of:

<compound-selector> = [ <type-selector>? <subclass-selector>*
                        [ <pseudo-element-selector> | <pseudo-class-selector> ]* ]!

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3876 using your GitHub account
Received on Thursday, 25 April 2019 21:49:06 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:46 UTC