Re: [csswg-drafts] [css-selectors-4] Selector for element with another element as ancestor (#9130)

Sorry, I think I didn’t explain the motivation for this. Obviously `a p` will match this in the general case, but I mean this as a convenience/maintainability solution in quite highly nested cases like this:

```css
.aleph {
  /* ... styles for .aleph ... */
  & .beth {
     /* ... styles for .aleph .beth ... */
    & .gimel {
      /* ... styles for .aleph .beth .gimel ... */
      & .daleth {
        /* ... styles for .aleph .beth .gimel .daleth ... */
        &:within(a) {
        /* special styles for .daleth when within a link, regardless of where the a
           is in the tree of .aleph .beth .gimel */
        } } } } }
```

The only equivalent of this using the whitespace selector would be to write out the combinations by hand, and exiting the entire tree of selectors where the rest of the styles for `.daleth` are:

```css
a .aleph .beth .gimel .daleth,
.aleph a .beth .gimel .daleth,
.aleph .beth a .gimel .daleth
.aleph .beth .gimel a .daleth {
  /* special styles for .daleth within a link */
}
```

This is long-winded and gets even more complicated if one imagines situations such as `.gewa:within(.bercna:within(.aza))` with a tree of selectors preceding it.

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


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

Received on Wednesday, 2 August 2023 08:12:07 UTC