@@ -1202,15 +1202,17 @@ That is, it is either an <em>empty</em> statement ended immediately by a semicol
1202
1202
or a block treated as a [=nested declarations rule=] .
1203
1203
The empty statement form behaves identically to passing an empty block.
1204
1204
1205
- If the [=mixin=] did not declare a ''@contents'' parameter,
1206
- the ''@contents'' rule is ignored,
1207
- substituting with nothing.
1208
- Otherwise, if the ''@apply'' rule invoking the [=mixin=] passed a [=contents block=] ,
1209
- the ''@contents'' is replaced with the [=contents block=] ,
1210
- treating it as a [=nested declarations rule=] .
1211
- Otherwise, if the ''@apply'' rule did not pass a [=contents block=] ,
1212
- the ''@contents'' rule is replaced with its own <<declaration-list>> ,
1213
- treated as a [=nested declarations rule=] .
1205
+ * If the [=mixin=] did not declare a ''@contents'' parameter,
1206
+ the ''@contents'' rule is ignored,
1207
+ substituting with nothing.
1208
+ <span class=note> (And if the ''@apply'' rule tries to pass a [=contents blocks=] ,
1209
+ it's an invalid invocation and has no effect.)</span>
1210
+ * Otherwise, if the ''@apply'' rule invoking the [=mixin=] passed a [=contents block=] ,
1211
+ the ''@contents'' is replaced with the [=contents block=] ,
1212
+ treating it as a [=nested declarations rule=] .
1213
+ * Otherwise, if the ''@apply'' rule did not pass a [=contents block=] ,
1214
+ the ''@contents'' rule is replaced with its own <<declaration-list>> ,
1215
+ treated as a [=nested declarations rule=] .
1214
1216
1215
1217
Outside of a [=mixin body=] ,
1216
1218
the ''@contents'' rule is invalid and ignored.
@@ -1280,6 +1282,26 @@ Its grammar is:
1280
1282
<<@apply>> = @apply [ <<dashed-ident>> | <<dashed-function>> ] [ { <<declaration-list>> } ]?;
1281
1283
</pre>
1282
1284
1285
+ <div class=example>
1286
+ For example, a [=mixin=] can be applied in any of these ways:
1287
+
1288
+ <pre highlight=css>
1289
+ .foo {
1290
+ @apply --one;
1291
+ /* Invokes the --one mixin, with no arguments or contents. */
1292
+
1293
+ @apply --two(blue);
1294
+ /* Invokes --two with one argument, and no contents. */
1295
+
1296
+ @apply --three {color: red;}
1297
+ /* Invokes --three with no arguments, but with contents.
1298
+
1299
+ @apply --four(blue) {color: red;}
1300
+ /* Invokes --four with both an argument and contents.
1301
+ }
1302
+ </pre>
1303
+ </div>
1304
+
1283
1305
The ''@apply'' rule is only valid
1284
1306
in the body of a [=style rule=]
1285
1307
or [=nested group rule=] ;
@@ -1313,6 +1335,40 @@ If the [=mixin=] did not declare a ''@contents'' parameter,
1313
1335
having a <<declaration-list>> block makes the ''@apply'' rule invalid
1314
1336
(similar to passing too many arguments).
1315
1337
1338
+ <div class=example>
1339
+ Applying a mixin without arguments, or with an empty argument list,
1340
+ is identical.
1341
+ That is, these two invocations do exactly the same thing:
1342
+
1343
+ <pre highlight=css>
1344
+ .foo {
1345
+ @apply --no-args;
1346
+ }
1347
+ .bar {
1348
+ @apply --no-args();
1349
+ }
1350
+ </pre>
1351
+
1352
+ Passing a [=contents block=] is <em> not</em> the same;
1353
+ omitting the block entirely triggers fallback,
1354
+ while passing an empty block will substitute the empty block:
1355
+
1356
+ <pre highlight=css>
1357
+ @mixin --just-contents(@contents) {
1358
+ @contents { content: "This is fallback." }
1359
+ }
1360
+
1361
+ .foo {
1362
+ @apply --just-contents;
1363
+ /* substitutes with `content: "This is fallback.";` */
1364
+ }
1365
+ .bar {
1366
+ @apply --just-contents {};
1367
+ /* substitutes with nothing at all */
1368
+ }
1369
+ </pre>
1370
+ </div>
1371
+
1316
1372
1317
1373
<!-- Big Text: @env
1318
1374
0 commit comments