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

Features Missing From CSS: Parent selector vs :has() #17

Closed
foolip opened this issue Jul 22, 2022 · 14 comments
Closed

Features Missing From CSS: Parent selector vs :has() #17

foolip opened this issue Jul 22, 2022 · 14 comments
Assignees
Labels
let's do this Accepted suggestion but not in survey yet State of CSS 2022

Comments

@foolip
Copy link

foolip commented Jul 22, 2022

I'd like to keep and tweak this question for 2021:
https://2021.stateofcss.com/en-US/opinions/#currently_missing_from_css_wins

Parent Selector is a tricky one, because there's now :has(), but it's different from the imagined parent selector as the reverse of the child selector. Options that I can see:

  • Keep asking about Parent Selector and see if it goes down as a result of shipping :has()
  • Drop the Parent Selector option here and add something else (needs to be 8 options)
  • Somehow explicitly ask "did :has() meet the use cases you wanted parent selectors for?" (other question)
@SachaG
Copy link
Member

SachaG commented Jul 22, 2022

Is there a proposal for a different parent selector in the works? If not I think we might as well consider that :has() is the best "parent selector" we'll get. As to whether it should still be considered "missing" I guess it depends if you answer based on what's in the spec (in which case it's not missing anymore) or what is actually usable today (in which case we're still not quite there).

I think it probably boils down to what we can replace it with, and since I can't think of much else right now I feel like we might end up leaving it in? Same issue with containment queries really…

@LeaVerou
Copy link
Collaborator

Somehow explicitly ask "did :has() meet the use cases you wanted parent selectors for?" (other question)

:has() is strictly more powerful than a parent selector that is the reverse of the child selector, so this is not really a subjective question.

@foolip
Copy link
Author

foolip commented Jul 29, 2022

https://drafts.csswg.org/selectors/#relational says that :has() can't be nested, isn't that a difference from the imaginary parent selector?

Ultimately I think we should ask about :has() as its own feature, and not do anything special.

I would be interested to see whether "parent selector" would still be a popular choice for this question if we kept it, but keeping doesn't make a whole lot of sense.

@LeaVerou
Copy link
Collaborator

LeaVerou commented Jul 29, 2022

I don't recall every detail of the relevant discussions, but I seem to remember that even without nesting, :has() is strictly more powerful than the subject selector as it can branch out on multiple different parts of the tree and the subject selector is strictly more powerful than the parent selector (by parent selector I assume something like a combinator that is the reverse of >). But it's entirely possible I'm misremembering and that's true only with :has() nesting. @tabatkins, maybe you remember?

Regardless, I agree that it probably doesn't make sense to use the term "parent selector" anywhere, unless what we are trying to measure is how many people have realized that :has() solves that problem.

@foolip
Copy link
Author

foolip commented Aug 4, 2022

@LeaVerou can you also add the "already in survey" label?

@SebastianZ
Copy link

unless what we are trying to measure is how many people have realized that :has() solves that problem.

I guess that's the point. I just had the case today that I told someone about :has() and he didn't realize that this is basically the parent selector with more powers.
I am sure that many more people out there don't know that :has() solves that problem.
Talking about authors not knowing about features, see also #35.

Sebastian

@LeaVerou LeaVerou changed the title Features Missing From CSS Features Missing From CSS: Parent selector vs :has() Aug 6, 2022
@LeaVerou
Copy link
Collaborator

LeaVerou commented Aug 6, 2022

Perhaps we could just rename "Parent selector" to "Parent selector / :has()"

@foolip
Copy link
Author

foolip commented Aug 22, 2022

Renaming to put :has() in the title might be the best, yeah. It won't have shipped in all browsers when the survey runs I think, so it still makes some sense to talk about it as missing.

@SebastianZ
Copy link

If @LeaVerou's altered survey questions are adopted, this will rather be part of unusable features due to little browser support.

Sebastian

@LeaVerou LeaVerou added let's do this Accepted suggestion but not in survey yet and removed in survey labels Aug 23, 2022
@LeaVerou
Copy link
Collaborator

Changing tags, since this does have an action item attached to it: Rename to "Parent selector / :has()"

@SachaG
Copy link
Member

SachaG commented Sep 23, 2022

The name of the feature will just be :has() I think. Using the term "parent selector" just adds confusion imo.

@SachaG SachaG closed this as completed Sep 23, 2022
@LeaVerou
Copy link
Collaborator

The name of the feature will just be :has() I think. Using the term "parent selector" just adds confusion imo.

What kind of confusion would something like "(aka Parent selector)" add?

@foolip
Copy link
Author

foolip commented Sep 25, 2022

"aka" sounds good, that conveys that it isn't the canonical name of the feature.

@SebastianZ
Copy link

The name of the feature will just be :has() I think. Using the term "parent selector" just adds confusion imo.

I am fine with that if there's a one-line explanation below it saying that it covers the use case of a parent selector and others.

Sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
let's do this Accepted suggestion but not in survey yet State of CSS 2022
Projects
None yet
Development

No branches or pull requests

4 participants