Skip to content

[css-cascade-6] change lower boundary keyword for @scope to "until" #7943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
grncdr opened this issue Oct 23, 2022 · 6 comments
Closed

[css-cascade-6] change lower boundary keyword for @scope to "until" #7943

grncdr opened this issue Oct 23, 2022 · 6 comments

Comments

@grncdr
Copy link

grncdr commented Oct 23, 2022

The current proposed syntax for @scope rules with a lower bound is:

@scope ([data-scope='main-component']) to ([data-scope]) {
  p { color: red; }

  /* only the outer section is part of the outer scope */
  section { background: snow; }
}

https://drafts.csswg.org/css-cascade-6/#at-ruledef-scope

A smaller change that was proposed in #6577 but did not get explored further (as far as I know) was using the keyword until instead of to for an exclusive lower bound. I'd like to request that "until" be considered as a more suitable keyword.

  • it clearly communicates that the lower bound is exclusive (which is great, I 1000% agree with that resolution).
  • it is less likely to be misread as the second selector being the container.

The above might require a bit of explanation: when discussing scope in other programming contexts (e.g. JavaScript) the statement "X is scoped to Y" designates Y as the container of X. A rule like @scope (.x) to (.y) does not have a similar meaning, despite looking superficially identical.

When searching for examples I found this article by Raymond Chen on this exact subject. While his article is about Microsoft, the usage is common across the internet.

There are many more examples on MDN: https://developer.mozilla.org/en-US/search?q=%22scoped%20to%22


I recognize this issue is a bit "bikesheddy" but I think it's a big improvement in readability for what is going to be a high-profile feature.

@grncdr
Copy link
Author

grncdr commented Oct 23, 2022

A comment with the same idea from last September: https://css-tricks.com/early-days-for-css-scoping/#comment-1782132

@mirisuzanne
Copy link
Contributor

Agenda+ to get group feedback on this. I don't have a strong leaning one way or the other.

@DarkWiiPlayer
Copy link

I agree that, intuitively, to makes me think the lower boundary is included. until would probably avoid some confusion there.

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-cascade-6] change lower boundary keyword for @scope to "until", and agreed to the following:

  • RESOLVED: close the issue as no-change
The full IRC log of that discussion <fremy> miriam: this is a bikeshedding issue open for a while
<fremy> miriam: the concern is that "scoped to" usually means "it's inside the scope"
<fremy> miriam: so it might be confusing to also use "to" to say that the scope goes "from...to"
<fantasai> wfm
<fremy> miriam: I have no strong opinion on it
<bramus> q+
<fremy> fremy: wfm too
<astearns> ack bramus
<TabAtkins> q+
<fremy> bramus: no hard feelings, but "to" sounded better to me, because as a non-native English speaker "until" is not very frequent
<fremy> bramus: this might also be related to the next issue
<astearns> ack TabAtkins
<fremy> bramus: if we choose to include the boundaries, "to" might be better
<fremy> TabAtkins: there is no clear English word that indicates exclusivity or inclusivity with clarity
<fremy> TabAtkins: so I don't think the choice of term is not that important
<fremy> TabAtkins: and therefore believe going with the shortest one makes the most sense
<astearns> ack fantasai
<fremy> fantasai: while I agree with TabAtkins that the inclusivity is not clear in either wording
<TabAtkins> "range from 0 to 3" can easily mean [0,1,2,3] or [0,1,2] depending on context. Even sometimes [1,2].
<fremy> fantasai: that said, I can understand the other argument
<fremy> fantasai: but maybe we could use something else than a word, like the > sign?
<bramus> q+
<TabAtkins> I think we should avoid `>` next to selectors, due its context-specific meaning there.
<fremy> fantasai: that would avoid the problems with the choice of an English word
<astearns> ack bramus
<fremy> bramus: the > sign is also a combinator
<fremy> miriam: but scoping extends in the same direction as the combinator
<fremy> miriam: so not a problem for me, though I still like "to" a bit better I guess
<fantasai> s/other argument/other argument about how "scoped to the X element" means using X as the scoping root/
<fremy> astearns: there doesn't seem to be passionate comments for any of the comments
<fremy> astearns: so maybe we should just leave things as they are, for lack of a huge reason to change
<bramus> +1
<fremy> astearns: "to" is easier to spell, and not any more precise
<fantasai> "thru", to use Tab's spelling :p
<fremy> miriam: ok, let's propose to close no change
<fremy> astearns: yes, and if someone has a stronger argument or more data etc we could revisit
<TabAtkins> The only clear range-based english keywords I've ever really seen were in Lisp's LOOP macro - "0 to " was inclusive, "0 below 3" was exclusive.
<fremy> fantasai: like a more compelling rationale or something
<fremy> astearns: any objection?
<fremy> RESOLVED: close the issue as no-change

@fantasai
Copy link
Collaborator

fantasai commented Mar 1, 2023

The other option that came up in the discussion was to use some symbol instead of a keyword, e.g. ">":

@scope ([data-scope='main-component']) > ([data-scope]) {
  p { color: red; }
}

@mirisuzanne
Copy link
Contributor

Closing for now - but it can always be re-opened if someone wants to make a stronger case for one of the alternatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants