Skip to content

Commit e937d96

Browse files
committed
[css-cascade-5] Draft layer-import syntax (#5681)
1 parent d5e38b2 commit e937d96

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

css-cascade-5/Overview.bs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,17 @@ Importing Style Sheets: the ''@import'' rule</h2>
122122
as if they were written literally into the stylesheet at the point of the ''@import''.
123123

124124
Any ''@import'' rules must precede all other valid at-rules and style rules in a style sheet
125-
(ignoring ''@charset''), or else the ''@import'' rule is invalid.
125+
(ignoring ''@charset'' and empty [=@layer=] definitions), or else the ''@import'' rule is invalid.
126126
The syntax of ''@import'' is:
127127

128128
<pre class='prod'>
129129
@import [ <<url>> | <<string>> ]
130+
[ layer(<<layer-ident>>?) ]?
130131
[ supports( [ <<supports-condition>> | <<declaration>> ] ) ]?
131132
<<media-query-list>>? ;</pre>
132133

133134
where the <<url>> or <<string>> gives the URL of the style sheet to be imported,
135+
the optional <<layer-ident>> assigns imported rules to the indicated [=cascade layer=],
134136
and the optional [<<supports-condition>>|<<declaration>>] and <<media-query-list>>
135137
(collectively, the <dfn export>import conditions</dfn>)
136138
state the conditions under which it applies.
@@ -145,6 +147,16 @@ Importing Style Sheets: the ''@import'' rule</h2>
145147
<pre>@import url("narrow.css") supports(display: flex) handheld and (max-width: 400px);</pre>
146148
</div>
147149

150+
<div class="example">
151+
The following layer imports load the style sheets into
152+
the ''framework component'' layer, and an un-named layer, respectively:
153+
154+
<pre>
155+
@import url("tabs.css") layer(framework component);
156+
@import url("override.css") layer();
157+
</pre>
158+
</div>
159+
148160
If a <<string>> is provided,
149161
it must be interpreted as a <<url>> with the same value.
150162

@@ -1104,22 +1116,9 @@ Cascade Layers</h3>
11041116
Declaring Cascade Layers: the ''@layer'' rule</h4>
11051117

11061118
The <dfn at-rule id="at-ruledef-layer">@layer</dfn> rule
1107-
defines an explicit [=cascade layer=],
1108-
with the option to assign style rules as either a block or an import.
1109-
1110-
The import syntax is:
1111-
1112-
<pre class='prod'>
1113-
@layer <<layer-ident>>? <<url>>;
1114-
</pre>
1115-
1116-
Such ''@layer'' import rules have the same restrictions and processing
1117-
as ''@import'' (see [[#at-import]]),
1118-
except that the imported rules are assigned to the indicated layer.
1119-
1120-
Issue(w3c/csswg-drafts#5681): Is ''@layer'' the proper way to handle layered url imports?
1119+
defines an explicit [=cascade layer=], with the option to assign style rules.
11211120

1122-
The block syntax is:
1121+
The block layer-assignment syntax is:
11231122

11241123
<pre class='prod'>
11251124
@layer <<layer-ident>>? {
@@ -1131,7 +1130,7 @@ Declaring Cascade Layers: the ''@layer'' rule</h4>
11311130
as a [=conditional rule=] [[CSS-CONDITIONAL-3]]
11321131
with a true condition.
11331132

1134-
In both cases the optional <dfn for='@layer'><<layer-ident>></dfn>
1133+
The optional <dfn for='@layer'><<layer-ident>></dfn>
11351134
is a [=CSS identifier=] (<<ident>>)
11361135
that represents its <dfn>layer name</dfn>.
11371136
If the [=layer name=] matches that of a [=cascade layer=]
@@ -1153,7 +1152,7 @@ Declaring Cascade Layers: the ''@layer'' rule</h4>
11531152
</pre>
11541153

11551154
Such empty ''@layer'' are allowed
1156-
anywhere either import ''@layer'' or block ''@layer'' rules are allowed.
1155+
anywhere either ''@import'' or other ''@layer'' rules are allowed.
11571156

11581157
Issue(w3c/csswg-drafts#5853): Provide an attribute for assigning link or style elements to cascade layers
11591158

@@ -1523,6 +1522,7 @@ Additions Since Level 4</h3>
15231522
The following features have been added since
15241523
<a href="https://www.w3.org/TR/css-cascade-4/">Level 4</a>:
15251524

1525+
* Added ''layer()'' option to [=@import=] definition.
15261526
* Added [=cascade layers=] to the [=cascade=] sort criteria.
15271527
* Defined style attributes as a distinct step of the [=cascade=] sort criteria.
15281528
* Introduced the ''@layer'' rule for defining cascade layers.

0 commit comments

Comments
 (0)