-
Notifications
You must be signed in to change notification settings - Fork 759
Description
This issue was raised on social media by @mayank99. The goal is to select a scope that has a given element in scope. However, since @scope only requires the 'subject' to be in-scope, and the contents of has are not selecting the subject, there is not currently any way to achieve this.
Here's a code-pen for experimenting.
It seems like this might be solvable (though not elegant) with a :scope-end selector (already proposed in another thread) that matches lower boundary elements:
@scope (my-scope) to (my-scope) {
:scope:has(a:not(:scope-end a)) { … }
}(You can get close to that solution by replacing :scope-end with my-scope - but it becomes fragile with further nesting.)
Since this issue seems specific to the :has() selector, the other approach might be changes on that end:
- Add a
:scope-has()selector that does a scoped version of the same thing. It's clear and to the point, but maybe a bit of a special case? - Resolve
:has()differently when it's used on the:scope()selector. This is even more of a heuristic special case, but it really gets to the point of the issue. We want to know if the scope has something.
Other ideas?
The relevant spec text is:
Their selectors can only match elements that are in scope. (This only applies to the subject; the rest of the selector can match unrestricted.)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status