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

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