Re: [csswg-drafts] [css-nesting] :selector-replace() pseudo-class function (#6330)

My comment was in #6977 was:

> First, I have to say I keep stumbling on use cases for this. Things like:
> 
> ```css
> .container {
>  & .widget {
>   .container.selected & {
>    /* FAIL, gets rewritten to .container.selected .container .widget, 
>       not .container.selected .widget */
>   }
>  } 
> }
> ```
> 
> Also, I agree my proposal in [#6330 (comment)](https://github.com/w3c/csswg-drafts/issues/6330#issuecomment-851615137) is overkill. Also, it introduces a CSS property that is not actually applied on any elements, but is just used to evaluate syntax. Yikes.
> 
> Instead, I think we should go for a simpler solution, with predefined names for going up 1, 2, 3, ... levels. Perhaps `&1`, `&2`, `&3` etc. Then the example above would become:
> 
> ```css
> .container {
>  & .widget {
>   &1.selected & {
>    /* Gets rewritten to .container.selected .widget */
>   }
>  } 
> }
> ```
> 
> Is `&1` cryptic? Yes. But it isn't more cryptic than `&` itself, and it kinda reminds me of `$1`, `$2` etc in JS string replacement.

It was upvoted by @argyleink and @romainmenke @lubomirblazekcz .

If we are broadening this issue to include suggestions like these, we should probably edit the title to reflect this.

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


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

Received on Wednesday, 11 January 2023 14:09:35 UTC