Re: [csswg-drafts] [css-cascade-6] Named scopes proposal (#9742)

> Create a named scope using a scope statement

That would be the `naming scopes as a way to reuse their selectors` use-case, which is somewhat distinct. Both cases raise the question: how do we handle duplicate scope names? I imagine that problem is solvable in both cases, but I wonder if they would require different solutions?

```css
@scope duplicate (.outer) {
  @scope duplicate (.inner) {
    /* Use the inner version of duplicate? */
    :scope(duplicate) .test {
      background: lightgreen;
    }
  }
}
```

I'm less sure about a solution for reusable named scopes…

```css
@scope foo (.start) to (.end);

@scope foo {
  p { color: red; }
}

/* does this change the definition of foo for the above paragraph? */
@scope foo (.end) to (.another);
```

I would expect the later statement to override the former, but that becomes a very surprising behavior if the two definitions of `@scope foo` come from different files. There's probably a way around that. But in order for these two features to use the same syntax, they would need the same solution. (I imagine that's why @kizu mentioned reuse as 'out of scope'?)

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


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

Received on Tuesday, 14 May 2024 16:54:55 UTC