Selector parsing tests refuse user action pseudo-classes after any pseudo-element, and anything after an element-backed one, which selectors-4 and css-pseudo-4 allow

Open
#65,828 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
css, html, javascript

Research direction

Start with the ten parsing tests named in the issue, especially the valid and invalid assertions in the listed files, and compare them with selectors-4 §3.6.3 and css-pseudo-4 §5. Update the assertions for selectors that are syntactically allowed; cases that never match can move to matching tests. Done when the affected parsing tests reflect the specification rules.

Written by the indexing model from the issue text.

Description

Two rules decide what may follow a pseudo-element:

  • selectors-4 §3.6.3: "This specification allows any pseudo-element to be followed by any combination of the logical combination pseudo-classes and the user action pseudo-classes." w3c/csswg-drafts#7647 also resolved "We intend to allow user interaction pseudos after highlight pseudos".
  • css-pseudo-4 §5: "All pseudo-classes and pseudo-elements are syntactically allowed after an element-backed pseudo-element […]; but some are disallowed from matching: The structural pseudo-classes, :has() pseudo-class, :scope pseudo-class, and :host/:host()/:host-context() pseudo-classes never match. ::part() never matches." ::part() and ::details-content are element-backed.

Ten parsing tests refuse selectors these rules allow: ::selection:hover and the other highlight pseudo-elements with :hover, ::column:hover, ::slotted(*):hover, ::part(mypart):first-child, ::part(foo):has(li), ::part(mypart)::part(anotherpart) and ::details-content:has(a), among others in the same files. #63932 (open) already moves the element-backed cases of pseudo-classes-after-part.html, parse-part.html and CSS-supports-details-content-pseudo-parsing.html to valid; the user action cases and pseudo-elements-after-part.html are not in it.

Steps to reproduce

Reproducer: https://gist.github.com/YevheniiKotyrlo/f725dd461c3ede3654f74e756440a308

git clone https://gist.github.com/f725dd461c3ede3654f74e756440a308.git wpt-pseudo-classes-after-pseudo-elements
cd wpt-pseudo-classes-after-pseudo-elements
sh ./run.sh

run.sh installs Playwright and runs repro.mjs, which reads both rules from the Editor's Drafts and the ten tests from wpt master, prints each refusing assertion with the rule that allows it, and asks CSS.supports('selector(…)') of Chromium, Firefox and WebKit for a selector of each kind. It exits 1 while both rules stand and a test refuses what they allow.

Expected

Each of these assertions expects the selector valid (or CSS.supports true): in highlight-pseudos.html, highlight-pseudos-search-text.tentative.html and highlight-pseudo-parsing.html the :hover cases; in column-pseudo-invalid.html, ::column:hover; in slotted-parsing.html and parse-slotted.html, ::slotted(…) with :hover or :focus; in pseudo-classes-after-part.html and parse-part.html, the structural pseudo-classes, :has(), :host, :host-context() and :scope after ::part(); in pseudo-elements-after-part.html, ::part(mypart)::part(anotherpart); and in CSS-supports-details-content-pseudo-parsing.html, ::details-content followed by :has(a) or ::part(a). Those that never match by §5 can move to matching tests.

Actual

Chromium, Firefox and WebKit refuse most of these today; WebKit accepts ::part(foo):has(li) and ::details-content:has(a). On Windows 11 with Node 26.12.1 and Playwright 1.65.0:

selectors-4 and css-pseudo-4 at revision 6f177f4c13fbc3153474b66e88c25cf58ce5cfdd; tests from web-platform-tests/wpt@c099c2e48107d6202489ae0976b53a732c3df5bd (master)
  selectors-4 §3.6.3: "This specification allows any pseudo-element to be followed by any combination of the logical combination pseudo-classes and the user action pseudo-classes."
  css-pseudo-4 §5: "All pseudo-classes and pseudo-elements are syntactically allowed after an element-backed pseudo-element (such as x-button::part(label):hover or x-button::part(label)::before), just as if the pseudo-element were a type selector; but some are disallowed from matching: The structural pseudo-classes, :has() pseudo-class, :scope pseudo-class, and :host/:host()/:host-context() pseudo-classes never match. ::part() never matches."
  css/css-pseudo/parsing/highlight-pseudos.html: test_invalid_selector(`${pseudo}:hover`)  (allowed by §3.6.3)
  css/css-pseudo/parsing/highlight-pseudos-search-text.tentative.html: test_invalid_selector(`${pseudo}:hover`)  (allowed by §3.6.3)
  css/css-highlight-api/highlight-pseudo-parsing.html: test_invalid_selector(`${pseudo}:hover`)  (allowed by §3.6.3)
  css/css-multicol/parsing/column-pseudo-invalid.html: test_invalid_selector("::column:hover")  (allowed by §3.6.3)
  css/css-shadow/slotted-parsing.html: test_invalid_selector("::slotted(*):hover")  (allowed by §3.6.3)
  css/selectors/parsing/parse-slotted.html: test_invalid_selector("::slotted(foo):hover")  (allowed by §3.6.3)
  css/css-shadow/part/pseudo-classes-after-part.html: test_invalid_selector("::part(mypart):first-child")  (allowed by §5)
  css/selectors/parsing/parse-part.html: test_invalid_selector("::part(foo):has(li)")  (allowed by §5)
  css/css-shadow/part/pseudo-elements-after-part.html: test_invalid_selector("::part(mypart)::part(anotherpart)")  (allowed by §5)
  css/css-conditional/js/CSS-supports-details-content-pseudo-parsing.html: CSS.supports("selector(::details-content:has(a)"), false  (allowed by §5)
playwright 1.65.0
chromium 158.0.8127.18: ::selection:hover invalid, ::highlight(foo):hover invalid, ::column:hover invalid, ::slotted(*):hover invalid, ::part(mypart):first-child invalid, ::part(foo):has(li) invalid, ::part(mypart)::part(anotherpart) invalid, ::details-content:has(a) invalid
firefox 159.0: ::selection:hover invalid, ::highlight(foo):hover invalid, ::column:hover invalid, ::slotted(*):hover invalid, ::part(mypart):first-child invalid, ::part(foo):has(li) invalid, ::part(mypart)::part(anotherpart) invalid, ::details-content:has(a) invalid
webkit 27.2: ::selection:hover invalid, ::highlight(foo):hover invalid, ::column:hover invalid, ::slotted(*):hover invalid, ::part(mypart):first-child invalid, ::part(foo):has(li) valid, ::part(mypart)::part(anotherpart) invalid, ::details-content:has(a) valid

SUMMARY: 10 of the 10 tests refuse a selector selectors-4 §3.6.3 or css-pseudo-4 §5 allows
Dominant language
HTML
Stars
6.3k
Forks
4.1k
Avg merge
17h 20m
Merged PRs (30d)
841

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from web-platform-tests/wpt

All issues in web-platform-tests/wpt

Similar issues

More Testing & QA issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.