[csswg-drafts] [selectors-4] Legacy `:` pseudo-element cannot appear before type/subclass selectors (#8122)

cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors-4] Legacy `:` pseudo-element cannot appear before type/subclass selectors ==
Chrome/FF seems to parse `:before#id` or `:before.class` as invalid (instead of valid and matching nothing) but I do not see on which part of the spec this is based.

  > *Pseudo-elements are featureless, and so can’t be matched by any other selector*

This does not make them invalid.

Legacy `:` pseudo-element syntax is defined in `<subclass-selector>` as a `<pseudo-class-selector>`.

  > *[...] pseudo-classes are allowed in all compound selectors [...] and must follow the type selector or universal selector, if present.*

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

Pseudo-classes and type/subclass selectors can appear in any order while still selecting the same element set, but this is not true for a pseudo-element specified with the legacy single `:` syntax.

Therefore I assume that `:before` must be handled as if it has been specified with `::before` and matched `<pseudo-element-selector>`, even if it matches `<pseudo-class-selector>`. **If so, it may be helpfull to define that in the spec.**

A [similar confusion](https://github.com/w3c/csswg-drafts/issues/6425#issuecomment-907733117) occurred to me when parsing a `<color-stop-list>`, whose syntax requires two color stops but its grammar accepts an implicit color stop defining two stops with the same color.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8122 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 22 November 2022 11:04:13 UTC