[csswg-drafts] [selectors-4] `x-pseudo-element` test is not documented in the selectors-4 spec (#6826)

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

== [selectors-4] `x-pseudo-element` test is not documented in the selectors-4 spec ==
https://github.com/web-platform-tests/wpt/pull/12743 created a test with the description of "x-prefixed pseudo-elements should make the whole rule invalid".

It's attached to **Section 3.6 Pseudo elements** ([see test table](http://test.csswg.org/suites/selectors-4_dev/nightly-unstable/html/chapter-3.htm)), however looking at the [draft version of the spec](https://drafts.csswg.org/selectors/#pseudo-elements), that behavior is not documented.  In fact, the only time "x-" appears in the entire spec is for within the words "complex-" or "max-".

It looks like the spec needs to be updated, however as an aside I'd like to mention that this change seems a bit weird.  Looking at the pull request that added the test and the attached webkit bug, I don't see any discussion about why the behavior was added.  Adding context would be helpful, since this seems like something that could be considered a breaking change for some parsers.

For context, here is the type of selector this test asserts to be invalid:
```
::x-something-nobody-would-think-of, p {
  color: red;
}
```

Slightly later in the spec, in **3.9 Invalid Selectors and Error Handling**, it states that "a selector list containing an invalid selector is invalid", however in 3.6 there is a line stating that "The host language defines which pseudo-elements exist".

This makes sense, I saw discussion in another bug about how "::-webkit"`-prefixed pseudo elements are only supported on webkit and invalidate the whole selector on other UAs.  I think the wording can be improved by updating the text to say something along the lines of

> The host language and UAs defines which pseudo-elements exist [...].  If a pseudo-element does not exist, the selector is invalid.

...

> UAs must not implement support for pseudo-elements prefixed with `x-`, such as `::x-pseudo-element`.

Now that I'm writing that, my expectation of that is actually the opposite.  For HTTP headers prefixing them with "X-" makes them ignored by the UA, so that it may be used for custom metadata and consumed by scripts.  Maybe the `::x-` pseudo prefix could operate the same way, providing a mechanism for user-defined pseudo elements?

If I missed something please let me know, but I spent the last hour or two scouring so if it is documented. It was not discoverable for me and may be a reason to amend the docs 🙂 

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


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

Received on Tuesday, 23 November 2021 21:47:27 UTC