[csswg-drafts] Add a property to retrieve plural instances of pseudo elements with the same selector (#12162)

danielsakhapov has just created a new issue for https://github.com/w3c/csswg-drafts:

== Add a property to retrieve plural instances of pseudo elements with the same selector ==
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)`](https://www.w3.org/TR/css-pseudo-4/#window-interface) 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`.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12162 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 5 May 2025 13:13:29 UTC