Skip to content

[css-pseudo-4] "Singular" vs "plural" pseudo-elements #9968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tabatkins opened this issue Feb 15, 2024 · 1 comment
Open

[css-pseudo-4] "Singular" vs "plural" pseudo-elements #9968

tabatkins opened this issue Feb 15, 2024 · 1 comment
Labels
css-pseudo-4 Current Work

Comments

@tabatkins
Copy link
Member

We discussed in the F2F that a few things being worked on need to be able to distinguish whether a pseudo-element is "singular" or "plural" - that is, if you target the pseudo-element (via a selector, a getComputedStyle() argument, etc) from a particular originating element, will you necessarily get 0/1 pseudo-element, or is it possible get N>1 pseudo-elements?

For example:

  • ::before is singular - only one exists on an element.
  • ::view-transition-group() is singular if a VT name is used (because names have to be document-unique), but plural otherwise (multiple VTs can have the same VT class, or the * argument matches all VTs).
  • ::part() is always plural - the part name has the semantics of a class, and can refer to any number of elements.

We should reify this concept in Pseudo, and specify that APIs like getComputedStyle() can only refer to singular pseudos, or conditionally-singular pseudos if certain conditions are met.

@tabatkins tabatkins added the css-pseudo-4 Current Work label Feb 15, 2024
@schenney-chromium
Copy link
Contributor

I would phrase it as "... supported when the style can be uniquely defined, either because there is only one (such as ::before) or because you must have a name that identifies the pseudo (such as ::highlight). Cases where there may be multiple do not get reported in getComputedStyle, even if there is only one that applies to the element."

That is basically a "yes/no" to whether support exists, with a way of explaining what the answer should be.

The alternative in my mind would be returning a list, but that's overkill to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-pseudo-4 Current Work
Projects
None yet
Development

No branches or pull requests

2 participants