w3c / w3c/csswg-drafts

[css-selectors] Reconsider removing selector list invalidation

Open
#3,082 8 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

selectors-5
Dominant language
Bikeshed
Stars
4.9k
Forks
816
Avg merge
2d 18h
Merged PRs (30d)
24

Description

https://drafts.csswg.org/selectors-4/#grouping

Warning: the equivalence is true in this example because all the selectors are valid selectors. If just one of these selectors were invalid, the entire selector list would be invalid. This would invalidate the rule for all three heading elements, whereas in the former case only one of the three individual heading rules would be invalidated.

I wasn’t aware of that for a long time and wrote many of my stylesheets with the assumption that a single unknown selector in a selector list wouldn’t invalidate the whole selector list[^1][^2].

Even in the specification, global selector list invalidation is said to be considered a legacy mistake in appendix B.

I propose to run a web study, similar to what Chrome did in #2156 to see if this very dumb[^3] legacy mistake can be fixed by getting rid of selector list invalidation.

[^1]: An actual selector list I once wrote:
css /* The `[data-ie]` attribute contains the string "legacy" for IE8 or older, and IE8 only supports the single‑colon `::before`/`::after` syntax */ html[data-ie~="legacy"] pre.line-numbers:before, pre.line-numbers::before { content: "1\A 2\A 3\A 4\A 5\A 6\A 7\A 8\A 9\A 10…"; /* all the way up to 9999 */ }

[^2]: Current known issues caused by this legacy mistake:
- MDN bug 1487656 (https://github.com/mozilla/kuma/pull/4961)
- #2156

[^3]: Yes, I have a very strong opinion about this.

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 by reviewing the Selectors 4 grouping section and Appendix B compatibility note, then compare the prior web-study discussion in #2156. Define a web study that measures the impact of removing selector-list invalidation and use its compatibility findings to determine whether the proposed specification change is viable.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.