4 ms·
:has() can be described as "elements whose children match some selectors". Your expectation would have been (if I understand it correctly) "match elements with
by uallo 4y ago
:has() can be described as "elements whose children match some selectors". Your expectation would have been (if I understand it correctly) "match elements with some selectors and get their (direct?) parent". Aside from reversing the logic, it seems to me that it is the exact same thing, isn't it? The selector could have been called "children pseudo-class selector" or similar, though.
Personally, I prefer the actual syntax over your expecation. The first thing in the selector are actual elements that will be styled if certain conditions are met. That also matches how the existing pseudo-classes have been applied.
> “if I’m in a hover state make my parent green, regardless of who/what the parent is”
*:has(> *:hover)
- samwillis 4y agoI think what they are suggesting, to invent some syntax, is this: :hover:parent() So it’s a post fix to go back up the tree. I prefer the flexibility of :has().