-
Notifications
You must be signed in to change notification settings - Fork 734
Description
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.
<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.