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

Conversation

andruud
Copy link
Member

@andruud andruud commented Nov 18, 2024

This will be needed to describe the new scope() function
for the @import prelude.
@andruud andruud requested a review from mirisuzanne November 18, 2024 23:14
@andruud
Copy link
Member Author

andruud commented Nov 18, 2024

Note that this PR has two commits. The first commit copies over the @import section from level 5, verbatim.

Note that the Media Query part still needs to appear last in the grammar
due to w3c#10972.
[ 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.

@cdoublev
Copy link
Collaborator

cdoublev commented Nov 28, 2024

Is it possible to edit Cascade 4 and 5 to prevent w3c/reffy from extracting <import-conditions>, which would be removed by this PR in Cascade 6?

- @import [ <url> | <string> ] ... <import-conditions> ;
- <import-conditions> = [ supports( [ <supports-condition> | <declaration> ] ) ]? <media-query-list>?
+ @import [ <url> | <string> ] ... [ supports( [ <supports-condition> | <declaration> ] ) ]? <media-query-list>? ;

Is it possible to define <supports()> and <media()> in Conditional 5, and <scope()> in Cascade 6, to avoid duplicate/overlapping definitions?

For example, supports() is defined differently in CSS Values 5, Conditional 5, Cascade 4/5.

<supports()>, <media()>, <media-query-list>, would define the import conditions.

@import [ <url> | <string> ]
        [[ layer | layer(<layer-name>) ] || <scope()> || <supports()> || <media()>]?
        <media-query-list> ;

<scope()> = scope( [ <scope-selector> | <scope-start> ]? )
<supports()> = supports( [ <supports-condition> | <declaration> ] )
<media()> = media( <media-query-list> )

Note: <media-query-list> does not need ? as it implicitly accepts an empty list.

<scope-selector> would be defined below the definition of @scope with @scope <scope-selector>? { ... }.

At least, the grouping brackets no longer seem necessary around scope(), now that it is implicitly optional.

@andruud
Copy link
Member Author

andruud commented Dec 5, 2024

@cdoublev That does sound quite reasonable, but I'll wait for an editor to have an opinion on what this should look like.

<media()> would be spec'ed later / separately, since we don't have a resolution to add it yet.


Trying another editor, since @mirisuzanne is unresponsive.

@andruud andruud requested review from fantasai and removed request for mirisuzanne December 5, 2024 08:26
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.

3 participants