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

[css-cascade-6] Support @import scope() syntax #11237

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions css-cascade-6/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,23 @@ Importing Style Sheets: the ''@import'' rule</h2>

<pre class='prod'>
@import [ <<url>> | <<string>> ]
[ layer | layer(<<layer-name>>) ]?
<<import-conditions>> ;
[[ layer | layer(<<layer-name>>) ]
|| [ scope( [ (<<scope-start>>) ]? [ to (<<scope-end>>) ]? | <<scope-start>> ) ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- [ scope( [ (<<scope-start>>) ]? [ to (<<scope-end>>) ]? | <<scope-start>> ) ]
+ [ scope( [ [ (<<scope-start>>) ]? [ to (<<scope-end>>) ]? ]! | <<scope-start>> ) ]

(do not allow empty alternative)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But @import scope() is valid, though. It gives you an "implicit scope", i.e. equivalent to @scope { }.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that is intentional then. Sorry! =)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this then be @import scope in parallel with @import layer?

I'd rather not have authors needing to remember:

valid invalid
@import layer @import layer()
@import scope() @import scope

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romainmenke Ah, yes, that's seems better.

|| <<supports-import-condition>>]?
<<media-import-condition>>?;

<dfn export>&lt;import-conditions></dfn> = [ supports( [ <<supports-condition>> | <<declaration>> ] ) ]?
<<media-query-list>>?</pre>
<dfn export>&lt;supports-import-condition></dfn> = [ supports( [ <<supports-condition>> | <<declaration>> ] ) ]
<dfn export>&lt;media-import-condition></dfn> = <<media-query-list>></pre>

where:

* the <<url>> or <<string>>
gives the URL of the style sheet to be imported.

* the optional ''layer'' keyword or ''layer()'' function
assigns the contents of the style sheet
and optionally:

* the ''layer'' keyword or ''layer()'' function,
which assigns the contents of the style sheet
into its own anonymous [=cascade layer=]
or into the named [=cascade layer=].

Expand All @@ -113,9 +117,24 @@ Importing Style Sheets: the ''@import'' rule</h2>
but is subject to any [=import conditions=]
(just as if declared by an ''@layer'' rule wrapped
in the appropriate [=conditional group rules=]).
* the ''scope()'' function,
which [=scopes=] the [=style rules=] within the stylesheet,
using the [=scoping roots=] and [=scoping limits=]
as described by [[#scope-limits]].

Note: While the [=style rules=] within the imported stylesheet
become [=scoped=],
they do not become [=nested style rule|nested=].
In particular,
top-level selectors are not re-interpreted as [=relative selectors=],
and the ''&'' pseudo-class maintains its non-nested behavior.

* the [=import conditions=],
<<supports-import-condition>> and <<media-import-condition>>,
which state the conditions under which the ''@import'' rule applies.

* the optional <<import-conditions>>
states the [=import conditions=] under which it applies.
Issue(10972): Accept <<media-import-condition>> at any point
after the URL/string.

<div class="example">
The following <a href="#conditional-import">conditional <css>@import</css> rule</a>
Expand All @@ -137,6 +156,15 @@ Importing Style Sheets: the ''@import'' rule</h2>
</pre>
</div>

<div class="example">
The following imports a stylesheet, and scopes the style rules
to elements matching <code>.card</code>.

<pre>
@import url("card.css") scope(.card);
</pre>
</div>

If a <<string>> is provided,
it must be interpreted as a <<url>> with the same value.

Expand Down Expand Up @@ -963,6 +991,11 @@ Changes since the 21 March 2023 Working Draft</h3>
Significant changes since the
<a href="https://www.w3.org/TR/2023/WD-css-cascade-6-20230321/">21 March 2023 Working Draft</a> include:

* Added the <code>@import scope()</code> syntax,
and the ability to specificy ''layer()'', ''scope()'', and ''supports()''
in any order.
(<a href="https://github.com/w3c/csswg-drafts/issues/7348">Issue 7348</a>)

* Allowed [=declarations=] directly within ''@scope''.
(<a href="https://github.com/w3c/csswg-drafts/issues/10389">Issue 10389</a>)

Expand Down