Re: [csswg-drafts] [selectors][css-nesting] Move nest-containing and nest-prefixed selector definitions to Selectors (#5745)

Another consideration…

>**TL;DR:** Any way to achieve the effect of the below example without using nesting, now that `&` cannot be used to reference the selector `:is`, `:where`, or `:has` was used on?
>```scss
>.a {
>  &:has(:is(& > .b:unsupported-pseudo, .c)) { ... } ✅
>}
>```

---

The below selector would not match `.a:has(> .b)`, right?

```scss
.a:has(:is(& > .b))
```

Instead, it would match `.a:has(:is(:root > .b:unsupported-pseudo))`, presumably… CMIIW.

So how might someone target a selector like `.a:has(> .b:unsupported-pseudo)` but make it forgiving if whatever assuming `:unsupported-pseudo` represents here. Per the recent jQuery scuffle over `:has()`, the official direction to make `:has()` forgiving has been to use `:has(:is())`, but how would that work without `&` in this case?:

```scss
.a:has(:is(& > .b:unsupported-pseudo, .c)) { ... }  ❌ (according to this new requirement)
```

Without `&`, that would look like this:

```scss
.a:has(:is(> .b:unsupported-pseudo, .c)) { ... } ❌
```

☝🏼 This wouldn't produce the intended result, would it, since it has no reference to use for the parent? With this new requirement, it seemingly necessitates using nesting in order to reference the parent like this.

What would a viable alternative be without having to spell the entire selector out again?

```scss
.long-classname:has(:is(.long-classname > .b:unsupported-pseudo, .c)) { ... } ❌
```

This should work, I think, but is there a way to achieve this same result without using nesting?:

```scss
.a {
  &:has(:is(& > .b:unsupported-pseudo, .c)) { ... } ✅
}
```

-- 
GitHub Notification of comment by brandonmcconnell
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5745#issuecomment-1379680118 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 12 January 2023 01:08:31 UTC