w3c / w3c/csswg-drafts

[selectors] The grammar for :host() and other compound-selector-taking things should probably forbid pseudo-elements

Open
#3,963 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

selectors-4
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

I just realized that WebKit (but not Blink nor Gecko) parse the following selector as valid:

:host(::before)

(or :host(::before)::before for that matter).

I was going to file a WebKit bug, but then realized that the grammar technically allows it. This also applies to the grammar of :is / :where (old :matches) etc.

I think that's wrong and pseudo-elements should not be allowed in nested selectors. WebKit itself doesn't parse, e.g., :not(::before), so they're not consistent about it.

Contributor guide

Open the contributing guide

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.

Research direction

Start with the selector grammar for :host(), :is(), :where(), and related compound-selector-taking constructs, comparing their treatment of nested pseudo-elements with :not(). Confirm the intended grammar and ensure pseudo-elements such as ::before are rejected in nested selectors while existing valid cases remain accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.