- From: Mason Freed via GitHub <sysbot+gh@w3.org>
- Date: Wed, 22 Jan 2025 18:21:36 +0000
- To: public-css-archive@w3.org
> > It seems to me like `querySelector()` and `matches()` just match in exactly the same way that a stylesheet selector would match. > > Wouldn't that make them depend on layout/style happening? That seems pretty bad and a major change in behavior. Maybe I'm misunderstanding what you mean? Oh, I see what you're saying. Yes, if this is defined as a new CSS property, then selectors (whether in a stylesheet or in a call to `querySelector`) will need to run style on descendent elements in order to determine whether `:hover` matches the ancestor. I think my confusion with the question is that this has nothing to do with JS in particular, does it? I'm also confused because we already have to run style/layout on descendants, since these pseudo classes are [already](https://drafts.csswg.org/selectors/#hover-pseudo:~:text=An%20element%20also%20matches%20%3Ahover%20if%20one%20of%20its%20descendants%20in%20the%20flat%20tree%20(including%20non%2Delement%20nodes%2C%20such%20as%20text%20nodes)%20matches%20the%20above%20conditions.) defined to match "if one of its descendants in the flat tree matches". Right? I'm not sure how this proposal changes that. Anyway, based on the feedback, here's a revised proposed resolution: ``` Proposed resolution: For an element E being matched by :hover, :active, :focus-within, or :target-within, flat tree descendants D that match the pseudo-class, but that are in the top layer (at a later position in the top layer stack, if E is also in the top layer) do not cause E to match the selector. In this case, all flat tree descendants of D also do not cause E to match the selector. ``` Sound better? The wording is tricky, but hopefully the above captures the important bits. -- GitHub Notification of comment by mfreed7 Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11185#issuecomment-2607953715 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 22 January 2025 18:21:37 UTC