-
Notifications
You must be signed in to change notification settings - Fork 719
[selectors] Child & descendant pseudo element combinators #7346
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
Comments
Related: #4565 |
Interesting! So with this proposal: *, * :>> * { box-sizing: border-box } …would apply border-box to everything. |
I hashed this out with Jake last week, and like this proposal; it addresses several of the pain points I've run into with pseudo-element syntax over the years. Small detail, probably obvious from the examples: when selecting into the "pseudo tree" of an element, the pseudo-elements are treated as having tagnames equal to their names, so you use type selectors to target them. Also, in chained pseudo-elements like Jake's listed motivations are all great, and why I'd like this. In particular, it would allow us to finally revise the data model of pseudo-elements to make some dang sense when combined with other features like relative selectors and nesting, which makes me very happy. The |
If something#very.long :> :is(before, after) /* something#very.long::before, something#very.long::after */ But this wouldn't work: something#very.long:is(*, * :> after) /* something#very.long, something#very.long::after */ |
Right, it would do the first but not the second. The second is still changing the subject of the selector, which is something that a pseudo-class fundamentally cannot do. We don't allow |
just a note
Making Update : This would be a major improvement imo. |
I don't think any new combinator will work out of the box. |
That I understand, but there is a subtle difference between a new combinator which isn't recognised as a combinator and something that causes tools to stop processing CSS. This is all fixable, but it will take time and considerable effort. I do think we need the |
Maybe we're saying the same thing, but every potential new combinator I try in https://parcel-css.vercel.app/ fails, except something like Have you found something that could work better? |
No and I think I've also been looking at the other side in tools -> how many bugs there are because So my initial opinion has changed from "this will be a lot of work" to "this will be a lot of work and a whole class of bugs might get fixed" |
Typically, if a complex selector matches an element, you can take just the last compound selector and it will still match. So if |
This cuts into the same issue as when we had the |
Suggest using |
Tab previously looked into |
Yeah, And without |
I'd like to bring up @bradkemper’s response to that old thread here:
|
The CSS Working Group just discussed
The full IRC log of that discussion |
Actually, the spec allows things like |
Yeah, but we undefined |
See also #5472 |
Uh oh!
There was an error while loading. Please reload this page.
Right now,
div::before::marker
means: Select the::marker
pseudo elements, that are a child of a::before
pseudo element, that originate from adiv
.There isn't a way to say: Select the
::marker
pseudo elements, that originate somewhere within the pseudo element tree of adiv
.It'd be great if we had a way to achieve this, such as:
:>
- select child pseudo elements. As in,div :> before :> marker
would be equivalent todiv::before::marker
:>>
- select descendant pseudo elements. As in,div :>> marker
would enable the use-case above.Future additions could include other combinators prefixed with
:
, such as:+
, to target adjacent sibling pseudo elements.This use-case came up in shared element transitions. Over there, we create pseudo-trees that are more complicated than (I think) we've seen in other features:
Our current model is to expose these through the following selectors:
html::page-transition-container(id)
html::page-transition-image-wrapper(id)
html::page-transition-outgoing-image(id)
html::page-transition-incoming-image(id)
However, these don't really communicate the structure, and won't play well with upcoming features like nesting, or
:has
.We'd like to expose the pseudos as they're structured, so instead of:
It would be:
Which plays well with nesting:
This would also allow for selectors like:
Note: According to #7463, the above won't be possible.
…which selects the
outgoing-image
pseudo element within apage-transition
pseudo element, that doesn't also have anincoming-image
. Although, for that particular case, I hope we can make something like this work:The text was updated successfully, but these errors were encountered: