Skip to content

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

@danielsakhapov

Description

@danielsakhapov

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions