Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scoping] Consider making :slotted(...) a pseudo class #7305

Open
devknoll opened this issue May 25, 2022 · 2 comments
Open

[scoping] Consider making :slotted(...) a pseudo class #7305

devknoll opened this issue May 25, 2022 · 2 comments
Labels
css-scoping-1 Current Work

Comments

@devknoll
Copy link

I'm having trouble finding prior discussion and I'm a noob and not a spec person, so apologies in advance.

::slotted(...) selects real elements within the same shadow tree as the selector, so it's unclear to me why it should be a pseudo element while e.g. :has(...)/:where(...)/:is(...)/:host(...)/:host-context(...) are all pseudo classes. One real world issue with this is that I can't querySelectorAll inside a shadow DOM for a ::slotted() selector, despite the selector targeting real elements by definition.

In contrast, ::part(...) being a pseudo element makes sense, since the element is essentially abstract from the point of view of the selector, since the actual element belongs to a different (shadow) tree.

There's probably some underlying reason here that I'm missing (and I would very much appreciate learning something new!) but otherwise this seems like it could be a nice low hanging improvement.

@devknoll devknoll changed the title Consider making :slotted(...) a pseudo class [selectors] Consider making :slotted(...) a pseudo class May 25, 2022
@devknoll devknoll changed the title [selectors] Consider making :slotted(...) a pseudo class [scoping] Consider making :slotted(...) a pseudo class May 25, 2022
@devknoll
Copy link
Author

If I had to guess, it was done this way because technically you are selecting a slot element with the ::slotted pseudo element. The slot belongs to the tree with the style, but the slotted content doesn't. I guess this makes sense.

Still sort of confusing though 😄

@devknoll
Copy link
Author

Some prior discussion and rationale here: whatwg/dom#463

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-scoping-1 Current Work
Projects
None yet
Development

No branches or pull requests

2 participants