- From: Roman Komarov via GitHub <sysbot+gh@w3.org>
- Date: Tue, 14 May 2024 18:52:04 +0000
- To: public-css-archive@w3.org
A few quick assorted thoughts (in a brainstorm mode): - I think the best would be to have the named scope be a dashed ident. So `@scope --foo …` instead of `@scope foo` (makes it possible to use any keywords alongside the name later). - For the duplicate nested names, I incline to make the innermost win, basically what I wrote in the issue: > Can the same name be used multiple times? I'd say that yes, in which case, similar to anonymous scopes, the innermost one would win. - After thinking about it for a while, I think that while the “reusing the selectors/scopes” can be treated as a separate issue, it does not necessarily conflict with this one. And it might be useful to think about both of them together, at least as a way to understand how each could build upon another. - I agree that when thinking about _reusable_ scopes, the hardest problem is how to handle multiple definitions. _Ideally_, I'd want to see them work without overriding each other: from the first `foo` mention in CSS it will apply to anything that follows it, as soon as it is mentioned the second time, the second mention takes precedence. This would be what authors could expect, and how it can be easily implemented in preprocessors. I guess the issue could be how to serialize something like that? I _think_ this is solvable, but yes, this is the most complex part. - If we have reusable named scopes, the `@scope --foo (.start) to (.end);` — an at-rule without a `{}` after it could be a good way to define them. If a scope has some content, I don't think it should create a new named scope _outside_ of itself. - Although, maybe we could introduce a special keyword for defining such a rule, so it _could_ be used with rules inside, like `define`, this way we could do either `@scope define --foo (.start) to (.end);` or `@scope define --foo (.start) to (.end) { … }` and have the `--foo` available outside as well (basically, a shorthand for `@scope --foo …; @scope --foo { … }`). - Inside a named scope (or outside if they're reusable), we could allow using some scope _inside other scope definitions_, introducing a `from` keyword: `@scope from --foo to (.another)` or `@scope (.another) to --foo` or `@scope from --foo to --bar`. - We'd need to introduce some way to mention the “start” and “end” of any scope, and come up with good defaults (I can think of use cases for any combination). - When we have a named scope, we could want to have a _negation_, like `@scope not --foo`, with styles inside matching anything that is _not_ inside this scope. - When we have two named scopes, we could want to be able to have an _intersection_ of them, basically to have a new scope that will match for elements that will match _both_ named scopes: `@scope --foo and --bar`. - I think this feature could be done iteratively: starting with just named scopes, then allowing add features that use it: reusable scopes, mentioning scopes as parts of other definitions, operations on scopes etc. …Ok, maybe I should stop for now :) Many of these could be potentially opened as separate issues, but it will make sense to do only if the proposal itself will be accepted. -- GitHub Notification of comment by kizu Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9742#issuecomment-2110919926 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 18:52:04 UTC