[csswg-drafts] [css-pseudo-4] Proxying pseudo-elements as "real" (`<slot>`) elements (#12575)

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

== [css-pseudo-4] Proxying pseudo-elements as "real" (`<slot>`) elements ==
This is an alternative idea to the many existing suggestions about improving access to pseudo-elements such as #12163.

The idea is that instead of figuring all kinds of different accessors to pseudo-elements, we would allow the author to create a real-DOM proxy for them, using a `<slot>` element. e.g.

```html
<menu>
  <>Menu content<>
  <slot name="::backdrop"></slot>
</menu>
```

The slot element wouldn't render anything on its own, but would rather be a "reference" to a pseudo-element, the backdrop of the menu in this case.
This pseudo element is now available using `querySelector` or any other DOM APIs,  it dispatches events in the normal way, it works with `getComputedStyle` and `getBoundingClientRect()`, and so forth. But rendering-wise it represents whatever the corresponding pseudo-element represents.

I think this would alleviate a lot of the issues raised about the pseudo-element specific JS APIs, though there are several things to be mindful around it.

@tabatkins @danielsakhapov @emilio @fantasai I wonder what you think about this approach.


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


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

Received on Tuesday, 5 August 2025 17:28:10 UTC