Skip to content

Add a property to retrieve plural instances of pseudo elements with the same selector #12162

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
danielsakhapov opened this issue May 5, 2025 · 0 comments
Labels
css-pseudo-4 Current Work

Comments

@danielsakhapov
Copy link
Contributor

Full context: https://github.com/danielsakhapov/CSSPseudoElementDoc?tab=readme-ov-file#33-plurality-multiple-pseudo-elements-of-the-same-kind

Description:
For pseudo elements like ::view-transition-old(*) / ::view-transition-new(*) (where * could match multiple captured elements with the same tag name), ::column pseudos and each can have distinct ::scroll-marker inside, how to retrieve all pseudos via Element.pseudo(type) which implies a single object per type?

  • Element.pseudo(type) returns the first or a representative one.
    • Pros: Simple, fits the current IDL.
    • Cons: Incomplete, doesn't allow access to other instances.
  • Introduce Element.pseudos(type) returning a NodeList-like collection (CSSPseudoElementList?).
    • Pros: Explicitly handles plurality. Aligns with DOM patterns like querySelectorAll.
    • Cons: Adds new API. How would items in the list be uniquely identified or ordered if they are not tree-abiding?
  • Parameterize potentially ambiguous pseudos, and let the parameter distinguish them (e.g. make ::column(selector)).
    • Pros: Uses an existing mechanism for some cases.
    • Cons: Not a general solution.

Recommendation:
We likely need an Element.pseudos(type) or a similar mechanism for pseudo elements that are inherently plural, as it's been requested by authors to e.g. add a click event listener to gather clicks statistics from every ::scroll-marker nested into ::column.

@danielsakhapov danielsakhapov added the css-pseudo-4 Current Work label May 5, 2025
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

1 participant