Re: [csswg-drafts] [css-pseudo] Can we make pseudo-elements first-class citizens in the DOM? (#11559)

A major issue with using an IDL interface for a pseudo element is that the lifecycle of some pseudo elements is not defined so they might get created, destroyed, duplicated at the style system's discretion.

A pseudo element is not an element, it is a mechanism to generate and style bits of a UI as a result of other style/layout, without it affecting the DOM.

One way to deal with this is to proxy pseudo elements with real elements, but that only works for some use cases and has its own caveats.

Perhaps an alternative way to approach this is to embrace the fact that pseudo elements are different, and add something like a "pseudoRoot" interface. This root would itself be defined in CSSOM, have an event target and can listen to pseudo element events without these events bubbling to the real element (or find some semantics similar to shadow bubbling), and can have bespoke functions for geometry, animation etc. in a way that takes into account the transient nature of pseudo elements. It can also expose primitives that can be used in IntersectionObserver etc without trying to appear like a stable reference to a transient object.

-- 
GitHub Notification of comment by noamr
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11559#issuecomment-3213539797 using your GitHub account


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

Received on Friday, 22 August 2025 08:29:45 UTC