Re: [csswg-drafts] How to handle addEventListener on `CSSPseudoElement`? (#12163)

The CSS Working Group just discussed ``How to handle addEventListener on `CSSPseudoElement`?``, and agreed to the following:

* `RESOLVED: pseudoTarget on selected event objects. no change to addEventListener. pseudoTarget is a CSSPseudoElement`

<details><summary>The full IRC log of that discussion</summary>
&lt;noamr> sakhapov: let's time we didn't have objections but we didn't resolve<br>
&lt;noamr> sakhapov: it's a CSSPsuedoElement object, which is a proxy of a pseudo-element. we want to support events on it. it's not an EventTarget. Instead, we add a pseudoTarget property to event objects that refer to it<br>
&lt;cwilso> s/let's/last<br>
&lt;noamr> sakhapov: we don't need it for every event, just for some events where this is relevant<br>
&lt;noamr> sakhapov: seems like it covers the use cases while remaining compatible<br>
&lt;noamr> lea: pseudoTarget is part of the event object?<br>
&lt;noamr> sakhapov: yes, in specific event types<br>
&lt;emilio> q+<br>
&lt;noamr> annevk: ui/animation/transition events<br>
&lt;noamr> sakhapov: there is some precedent<br>
&lt;noamr> annevk: alway there<br>
&lt;noamr> sakhapov: it would be a CSSPseudoElement object<br>
&lt;noamr> lea: can a single event correspond to multiple pseudo-elements?<br>
&lt;noamr> lea: e.g. when clicking on one pseudo-element might be clicking on multiple pseudo-elements<br>
&lt;noamr> emilio: this can happen today with before/after<br>
&lt;noamr> dbaron: the target is the inner-most thing. But CSSPseudoElement might be able to traverse<br>
&lt;noamr> sakhapov: target is always the element. pseudoTarget is the deepest pseudo element. CSSPseudoElement would manage the chain, e.g. pseudoTarget.parent<br>
&lt;masonf> q+<br>
&lt;noamr> annevk: if you wanted to go there. or a "path" like in events today<br>
&lt;noamr> emilio: is that well defined with boundary events?<br>
&lt;noamr> sakhapov: this won't work for boundary events atm<br>
&lt;noamr> emilio: so the psuedoTarget for these is always null at the moment<br>
&lt;masonf> q-<br>
&lt;noamr> emilio: makes sense<br>
&lt;emilio> ack emilio<br>
&lt;noamr> sakhapov: worth to mention that CSSPseduoElement is identity consistent<br>
&lt;noamr> zcorpan: even if you display:none the element?<br>
&lt;noamr> sakhapov: yes, it's just a proxy<br>
&lt;noamr> annevk: is it reset at some point?<br>
&lt;noamr> sakhapov: I don't think it's spec'ed<br>
&lt;noamr> masonf: the proxy exists regardless of the element<br>
&lt;noamr> annevk: so elements outside of the tree have pseudo-elements?<br>
&lt;dbaron> dbaron: could have some sort of weak reference GC semantics?<br>
&lt;dbaron> noamr: a pseudo-element is just an element-string pair, you don't need that<br>
&lt;dbaron> s/pseudo-element/CSSPseudoElement/<br>
&lt;noamr> Proposed resolution: pseudoTarget on selected event objects. no change to addEventListener. pseudoTarget is a CSSPseudoElement<br>
&lt;noamr> RESOLVED: pseudoTarget on selected event objects. no change to addEventListener. pseudoTarget is a CSSPseudoElement<br>
&lt;noamr> github: end topic<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12163#issuecomment-3468779171 using your GitHub account


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

Received on Thursday, 30 October 2025 16:05:23 UTC