Add the syntax definition for the import rule (#3294)

This commit is contained in:
Christophe Coevoet 2022-04-26 21:34:58 +02:00 committed by GitHub
parent 066d10831d
commit 012f79f373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View File

@ -6,6 +6,23 @@ still supported for backwards-compatibility.
[`@use` rule]: use.md
## Table of Contents
* [Syntax](#syntax)
* [Semantics](#semantics)
## Syntax
<x><pre>
**ImportRule** ::= '@import' ImportArgument (',' ImportArgument)*
**ImportArgument** ::= ImportUrl ImportSupportsDeclaration? [MediaQueryList][]?
**ImportUrl** ::= QuotedString | [InterpolatedUrl][]
**ImportSupportsDeclaration** ::= 'supports(' SupportsDeclaration ')'
</pre></x>
[InterpolatedUrl]: ../syntax.md#InterpolatedUrl
[MediaQueryList]: media.md#syntax
## Semantics
To execute an `@import` rule `rule`:
@ -16,8 +33,9 @@ To execute an `@import` rule `rule`:
* `argument`'s URL string begins with `http://` or `https://`.
* `argument`'s URL string ends with `.css`.
* `argument`'s URL string is syntactically defined as a `url()`.
* `argument` has a media query and/or a supports query.
* `argument`'s URL is an `InterpolatedUrl`.
* `argument` has an `ImportSupportsDeclaration`.
* `argument` has a `MediaQueryList`.
> Note that this means that imports that explicitly end with `.css` are
> treated as plain CSS `@import` rules, rather than importing stylesheets as

View File

@ -7,6 +7,7 @@
* [Vendor Prefix](#vendor-prefix)
* [Grammar](#grammar)
* [`InterpolatedIdentifier`](#interpolatedidentifier)
* [`InterpolatedUrl`](#interpolatedurl)
* [`Name`](#name)
* [`SpecialFunctionExpression`](#specialfunctionexpression)
* [`PseudoSelector`](#pseudoselector)
@ -50,6 +51,17 @@ as the *unprefixed identifier*.
No whitespace is allowed between components of an `InterpolatedIdentifier`.
### `InterpolatedUrl`
<x><pre>
**InterpolatedUrl** ::= 'url(' (QuotedString | InterpolatedUnquotedUrlContents) ')'
**InterpolatedUnquotedUrlContents** ::= ([unescaped url contents][] | [escape][] | Interpolation)*
</pre></x>
[unescaped url contents]: https://www.w3.org/TR/css-syntax-3/#url-token-diagram
No whitespace is allowed between components of an `InterpolatedUnquotedUrlContents`.
### `Name`
<x><pre>