Skip to content
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

Test for a nested :scope inside an :is() #43697

Merged

Conversation

kizu
Copy link
Contributor

@kizu kizu commented Dec 15, 2023

Quoting the specs for :scope,

The :scope pseudo-class represents this scoping root […].

In the following code, there is a scoping root: the .a.

      @scope (.a) {
        .b {
          &:is(:scope.x *) {
            z-index: 1;
          }
      }

However, right now, in the Chromium implementation, when the :scope is mentioned inside nesting, does not “see” the wrapping @scope, and treats it as :root, according to

If there is no scoping root then :scope represents the root of the document (equivalent to :root).

However, this is only true if we'd take the inner &:is(:scope.x *) in isolation, but because it is, in fact, inside the @scope, it should detect the scoping root, as we can think of it as :scope .foo:is(:scope:hover *), which works (see it in action in the CodePen where I stumbled upon this: https://codepen.io/kizu/pen/NWoZYwK); I did also add it as an assertion.

This is not an abstract example, and having this case to work as in the test assertion will be very useful for authors. It could allow us to use this method to clarify the conditions over the root node from inside the nesting, similar to how @at-root works in Sass, or how root reference works in Stylus.

cc @mirisuzanne

Update: cross-linking a Chromium bug I filled about this: https://bugs.chromium.org/p/chromium/issues/detail?id=1512217

@nt1m nt1m requested a review from mdubet December 20, 2023 07:49
@mdubet
Copy link
Contributor

mdubet commented Dec 20, 2023

To my understanding of the spec, the inner rule selector should be :is(:scope .b):is(:scope.x *) with :scope representing any .a elements of the page.

The test seems fine (albeit fairly complex to follow 😅), it looks like an implementation bug in Chromium (FWIW, it passes on WebKit main).

@andruud andruud merged commit bc19e8e into web-platform-tests:master Jan 3, 2024
19 checks passed
@kizu kizu deleted the css-cascade-scope-nesting-inside-is branch January 6, 2024 21:19
marcoscaceres pushed a commit that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants