fix(css/parser): Improve parsing of media queries (#5567)

This commit is contained in:
Alexander Akait 2022-08-30 06:18:43 +03:00 committed by GitHub
parent 5028658269
commit 5c28d00516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 1164 additions and 42 deletions

View File

@ -187,7 +187,7 @@ pub struct MediaQueryList {
pub struct MediaQuery {
pub span: Span,
pub modifier: Option<Ident>,
pub media_type: Option<Ident>,
pub media_type: Option<MediaType>,
pub keyword: Option<Ident>,
pub condition: Option<MediaConditionType>,
}
@ -200,6 +200,13 @@ impl EqIgnoreSpan for MediaQuery {
}
}
#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]
pub enum MediaType {
#[tag("Ident")]
Ident(Ident),
}
#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]
pub enum MediaConditionType {

View File

@ -397,6 +397,13 @@ where
}
}
#[emitter]
fn emit_media_type(&mut self, n: &MediaType) -> Result {
match n {
MediaType::Ident(n) => emit!(self, n),
}
}
#[emitter]
fn emit_media_condition_type(&mut self, n: &MediaConditionType) -> Result {
match n {

View File

@ -61,7 +61,11 @@ impl Visit for NoDuplicateAtImportRules {
if let Some(queries) = import_prelude.media.as_ref().map(|media| &media.queries) {
queries.iter().fold(&mut self.imports, |imports, query| {
let media = query.media_type.as_ref().map(|ident| ident.value.clone());
let media = query.media_type.as_ref().map(|ident| {
let MediaType::Ident(Ident { value, .. }) = ident;
value.clone()
});
let pair = (href.clone(), media);
if imports.contains(&pair) {

View File

@ -1216,7 +1216,8 @@ where
let start_pos = self.input.cur_span()?.lo;
let state = self.input.state();
let mut modifier = if is_one_of_case_insensitive_ident!(self, "not", "only") {
let is_not = is_one_of_case_insensitive_ident!(self, "not");
let modifier = if is_one_of_case_insensitive_ident!(self, "not", "only") {
let modifier = Some(self.parse()?);
self.input.skip_ws()?;
@ -1226,57 +1227,77 @@ where
None
};
let mut last_pos = self.input.last_pos()?;
if is!(self, "(") {
if is_not {
self.input.reset(&state);
}
let media_type = if !is!(self, Ident)
|| is_one_of_case_insensitive_ident!(self, "not", "and", "or", "only")
{
None
let condition: MediaCondition = self.parse()?;
Ok(MediaQuery {
span: Span::new(start_pos, condition.span.hi, Default::default()),
modifier: None,
media_type: None,
keyword: None,
condition: Some(MediaConditionType::All(condition)),
})
} else {
let media_type = Some(self.parse()?);
last_pos = self.input.last_pos()?;
self.input.skip_ws()?;
media_type
};
let mut keyword = None;
let mut condition_without_or = None;
let mut keyword = None;
let condition = if media_type.is_some() {
if is_one_of_case_insensitive_ident!(self, "and") {
keyword = Some(self.parse()?);
self.input.skip_ws()?;
let condition_without_or: MediaConditionWithoutOr = self.parse()?;
last_pos = condition_without_or.span.hi;
Some(MediaConditionType::WithoutOr(condition_without_or))
} else {
None
condition_without_or = Some(MediaConditionType::WithoutOr(self.parse()?));
}
} else {
modifier = None;
self.input.reset(&state);
let end_pos = if let Some(MediaConditionType::WithoutOr(condition_without_or)) =
&condition_without_or
{
condition_without_or.span.hi
} else if let Some(MediaType::Ident(ident)) = &media_type {
ident.span.hi
} else {
unreachable!();
};
let condition: MediaCondition = self.parse()?;
Ok(MediaQuery {
span: Span::new(start_pos, end_pos, Default::default()),
modifier,
media_type,
keyword,
condition: condition_without_or,
})
}
}
}
last_pos = condition.span.hi;
impl<I> Parse<MediaType> for Parser<I>
where
I: ParserInput,
{
fn parse(&mut self) -> PResult<MediaType> {
match cur!(self) {
_ if !is_one_of_case_insensitive_ident!(self, "not", "and", "or", "only", "layer") => {
Ok(MediaType::Ident(self.parse()?))
}
_ => {
let span = self.input.cur_span()?;
Some(MediaConditionType::All(condition))
};
Ok(MediaQuery {
span: Span::new(start_pos, last_pos, Default::default()),
modifier,
media_type,
keyword,
condition,
})
Err(Error::new(
span,
ErrorKind::Expected(
"ident (exclude the keywords 'only', 'not', 'and', 'or' and 'layer')",
),
))
}
}
}
}

View File

@ -430,6 +430,8 @@ impl Visit for SpanVisualizer<'_> {
mtd!(MediaQuery, visit_media_query);
mtd!(MediaType, visit_media_type);
mtd!(MediaCondition, visit_media_condition);
mtd!(MediaConditionWithoutOr, visit_media_condition_without_or);

View File

@ -804,6 +804,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/document/input.css:19:5]
19 | @media screen and (min-width: 900px) {
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/document/input.css:19:5]
19 | @media screen and (min-width: 900px) {

View File

@ -592,6 +592,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:10:1]
10 | @import "common.css" screen;
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:10:1]
10 | @import "common.css" screen;
@ -658,6 +664,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:11:1]
11 | @import url('landscape.css') screen and (orientation:landscape);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:11:1]
11 | @import url('landscape.css') screen and (orientation:landscape);
@ -1276,6 +1288,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:19:1]
19 | @import url("narrow.css") supports(display: flex) handheld and (max-width: 400px);
: ^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:19:1]
19 | @import url("narrow.css") supports(display: flex) handheld and (max-width: 400px);
@ -1450,6 +1468,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:20:1]
20 | @import url("narrow.css") SUPPORTS(display: flex) handheld and (max-width: 400px);
: ^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:20:1]
20 | @import url("narrow.css") SUPPORTS(display: flex) handheld and (max-width: 400px);
@ -2613,6 +2637,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:46:1]
46 | @import url(test.css) screen and (orientation:landscape);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:46:1]
46 | @import url(test.css) screen and (orientation:landscape);
@ -2739,6 +2769,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:47:1]
47 | @import url(test.css) SCREEN AND (ORIENTATION: LANDSCAPE);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:47:1]
47 | @import url(test.css) SCREEN AND (ORIENTATION: LANDSCAPE);
@ -2865,6 +2901,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:48:1]
48 | @import url(test.css)screen and (orientation:landscape);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:48:1]
48 | @import url(test.css)screen and (orientation:landscape);
@ -2991,6 +3033,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:49:1]
49 | @import url(test.css) screen and ( orientation : landscape ) ;
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:49:1]
49 | @import url(test.css) screen and ( orientation : landscape ) ;
@ -3117,6 +3165,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:50:1]
50 | @import url(test.css) screen and (orientation:landscape);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:50:1]
50 | @import url(test.css) screen and (orientation:landscape);
@ -5089,6 +5143,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:109:1]
109 | @import "test.css" supports(display: flex) screen and (orientation:landscape);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:109:1]
109 | @import "test.css" supports(display: flex) screen and (orientation:landscape);
@ -5227,6 +5287,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:110:1]
110 | @import"test.css"supports(display: flex)screen and (orientation:landscape);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:110:1]
110 | @import"test.css"supports(display: flex)screen and (orientation:landscape);
@ -5995,6 +6061,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:130:1]
130 | @import url("./test.css") supports(display: flex) screen and (min-width: 400px);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:130:1]
130 | @import url("./test.css") supports(display: flex) screen and (min-width: 400px);
@ -6331,6 +6403,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:133:1]
133 | @import url("./test.css") layer(default) supports(display: flex) screen and (min-width: 400px);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:133:1]
133 | @import url("./test.css") layer(default) supports(display: flex) screen and (min-width: 400px);
@ -6511,6 +6589,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:134:1]
134 | @import url("./test.css") layer supports(display: flex) screen and (min-width: 400px);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:134:1]
134 | @import url("./test.css") layer supports(display: flex) screen and (min-width: 400px);
@ -6697,6 +6781,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:135:1]
135 | @import url("./test.css") layer() supports(display: flex) screen and (min-width: 400px);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:135:1]
135 | @import url("./test.css") layer() supports(display: flex) screen and (min-width: 400px);
@ -6931,6 +7021,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:137:1]
137 | @import url("http://example.com/style.css") supports(display: flex) screen and (min-width: 400px);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:137:1]
137 | @import url("http://example.com/style.css") supports(display: flex) screen and (min-width: 400px);
@ -7135,6 +7231,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:138:1]
138 | @import url("./test.css")layer(default)supports(display: flex)screen and (min-width:400px);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:138:1]
138 | @import url("./test.css")layer(default)supports(display: flex)screen and (min-width:400px);
@ -7279,6 +7381,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:139:1]
139 | @import url("./test.css")screen and (min-width: 400px);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:139:1]
139 | @import url("./test.css")screen and (min-width: 400px);
@ -7483,6 +7591,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:140:1]
140 | @import url("./test.css") layer( default ) supports( display : flex ) screen and ( min-width : 400px );
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:140:1]
140 | @import url("./test.css") layer( default ) supports( display : flex ) screen and ( min-width : 400px );
@ -7687,6 +7801,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:141:1]
141 | @import url("./test.css") LAYER(DEFAULT) SUPPORTS(DISPLAY: FLEX) SCREEN AND (MIN-WIDTH: 400PX);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:141:1]
141 | @import url("./test.css") LAYER(DEFAULT) SUPPORTS(DISPLAY: FLEX) SCREEN AND (MIN-WIDTH: 400PX);
@ -7891,6 +8011,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:142:1]
142 | @import url("./test.css") /* Comment */ layer(/* Comment */default/* Comment */) /* Comment */ supports(/* Comment */display/* Comment */:/* Comment */ flex/* Comment */)/* Comment */ screen/* Comment */ and/* Comment */ (/* Comment */min-width/* Comment */: /* Comment */400px/* Comment */);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:142:1]
142 | @import url("./test.css") /* Comment */ layer(/* Comment */default/* Comment */) /* Comment */ supports(/* Comment */display/* Comment */:/* Comment */ flex/* Comment */)/* Comment */ screen/* Comment */ and/* Comment */ (/* Comment */min-width/* Comment */: /* Comment */400px/* Comment */);
@ -8131,6 +8257,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:145:1]
145 | @import url(test.css) /* Comment */ print and (orientation:landscape);
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:145:1]
145 | @import url(test.css) /* Comment */ print and (orientation:landscape);
@ -8257,6 +8389,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:146:1]
146 | @import /* Comment */ url(test.css) /* Comment */ print and (orientation:landscape);
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:146:1]
146 | @import /* Comment */ url(test.css) /* Comment */ print and (orientation:landscape);
@ -8959,6 +9097,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/import/input.css:154:1]
154 | @import url("./import-with-supports-and-media.css") supports(display: flex) screen and (min-width: 400px);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/import/input.css:154:1]
154 | @import url("./import-with-supports-and-media.css") supports(display: flex) screen and (min-width: 400px);

View File

@ -170,6 +170,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:1:1]
1 | @\media screen {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:1:1]
1 | @\media screen {}
@ -218,6 +224,12 @@
: ^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:2:1]
2 | @\media \screen {}
: ^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:2:1]
2 | @\media \screen {}
@ -266,6 +278,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:4:1]
4 | @media all {}
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:4:1]
4 | @media all {}
@ -314,6 +332,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:5:1]
5 | @media screen {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:5:1]
5 | @media screen {}
@ -362,6 +386,12 @@
: ^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:6:1]
6 | @media print {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:6:1]
6 | @media print {}
@ -410,6 +440,12 @@
: ^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:7:1]
7 | @media screen and (color) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:7:1]
7 | @media screen and (color) {}
@ -506,6 +542,12 @@
: ^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:8:1]
8 | @media screen and (color), projection and (color) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:8:1]
8 | @media screen and (color), projection and (color) {}
@ -566,6 +608,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:8:1]
8 | @media screen and (color), projection and (color) {}
: ^^^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:8:1]
8 | @media screen and (color), projection and (color) {}
@ -662,6 +710,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:9:1]
9 | @media screen and ( color ) , projection and ( color ) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:9:1]
9 | @media screen and ( color ) , projection and ( color ) {}
@ -722,6 +776,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:9:1]
9 | @media screen and ( color ) , projection and ( color ) {}
: ^^^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:9:1]
9 | @media screen and ( color ) , projection and ( color ) {}
@ -818,6 +878,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:10:1]
10 | @media print and (min-resolution: 118dpcm) {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:10:1]
10 | @media print and (min-resolution: 118dpcm) {}
@ -944,6 +1010,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:11:1]
11 | @media all {}
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:11:1]
11 | @media all {}
@ -992,6 +1064,12 @@
: ^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:12:1]
12 | @media screen and (color) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:12:1]
12 | @media screen and (color) {}
@ -1088,6 +1166,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:13:1]
13 | @media screen and ( color ) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:13:1]
13 | @media screen and ( color ) {}
@ -1190,6 +1274,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:15:1]
15 | @media not all and (monochrome) {}
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:15:1]
15 | @media not all and (monochrome) {}
@ -1292,6 +1382,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:16:1]
16 | @media not screen and (color), print and (color) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:16:1]
16 | @media not screen and (color), print and (color) {}
@ -1352,6 +1448,12 @@
: ^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:16:1]
16 | @media not screen and (color), print and (color) {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:16:1]
16 | @media not screen and (color), print and (color) {}
@ -1694,6 +1796,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:19:1]
19 | @media not all {}
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:19:1]
19 | @media not all {}
@ -1748,6 +1856,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:20:1]
20 | @media not all {}
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:20:1]
20 | @media not all {}
@ -1802,6 +1916,12 @@
: ^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:22:1]
22 | @media only screen and (color) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:22:1]
22 | @media only screen and (color) {}
@ -1904,6 +2024,12 @@
: ^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:23:1]
23 | @media only screen and ( color ) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:23:1]
23 | @media only screen and ( color ) {}
@ -12596,6 +12722,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:107:1]
107 | @media NOT all {}
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:107:1]
107 | @media NOT all {}
@ -12650,6 +12782,12 @@
: ^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:108:1]
108 | @media ONLY screen AND (color) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:108:1]
108 | @media ONLY screen AND (color) {}
@ -13382,6 +13520,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:115:1]
115 | @media tty {}
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:115:1]
115 | @media tty {}
@ -13438,6 +13582,12 @@
: ^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:117:1]
117 | @media print {
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:117:1]
117 | @media print {
@ -13649,6 +13799,12 @@
: ^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/media/input.css:124:1]
124 | @media print {
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/media/input.css:124:1]
124 | @media print {

View File

@ -619,6 +619,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/at-rule/supports/input.css:12:5]
12 | @media screen and (min-width: 900px) {
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/at-rule/supports/input.css:12:5]
12 | @media screen and (min-width: 900px) {

View File

@ -449,6 +449,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/comment/input.css:23:1]
23 | @media/* comment */screen/* comment */{}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/comment/input.css:23:1]
23 | @media/* comment */screen/* comment */{}
@ -497,6 +503,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/comment/input.css:24:1]
24 | @media /* comment */ screen /* comment */ {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/comment/input.css:24:1]
24 | @media /* comment */ screen /* comment */ {}

View File

@ -241,6 +241,12 @@
: ^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/csstree/1/input.css:6:1]
6 | @media screen and (foo: 1) {
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/csstree/1/input.css:6:1]
6 | @media screen and (foo: 1) {
@ -3203,6 +3209,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/csstree/1/input.css:44:1]
44 | @import 'foo' screen;
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/csstree/1/input.css:44:1]
44 | @import 'foo' screen;

View File

@ -65,6 +65,12 @@
: ^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/esbuild/misc/BIDuS3X-CUq54w1iGLX2ig/input.css:1:1]
1 | @import url("foo.css") print;
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/esbuild/misc/BIDuS3X-CUq54w1iGLX2ig/input.css:1:1]
1 | @import url("foo.css") print;

View File

@ -65,6 +65,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/esbuild/misc/OEG8DCXSJeDTU7pt4fTE-g/input.css:1:1]
1 | @import url("foo.css") screen and (orientation:landscape);
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/esbuild/misc/OEG8DCXSJeDTU7pt4fTE-g/input.css:1:1]
1 | @import url("foo.css") screen and (orientation:landscape);

View File

@ -41,6 +41,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/esbuild/misc/XVEwpuBI9VyrQMNs3Ow9Ag/input.css:1:1]
1 | @media screen {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/esbuild/misc/XVEwpuBI9VyrQMNs3Ow9Ag/input.css:1:1]
1 | @media screen {}

View File

@ -41,6 +41,12 @@
: ^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/esbuild/misc/fkG7TT4zrV2k19c3t785gQ/input.css:1:1]
1 | @media \0screen\,screen\9 {}
: ^^^^^^^^^^^^^^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/esbuild/misc/fkG7TT4zrV2k19c3t785gQ/input.css:1:1]
1 | @media \0screen\,screen\9 {}

View File

@ -46,6 +46,12 @@
: ^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/feature/input.css:1:1]
1 | @media screen and (color) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/feature/input.css:1:1]
1 | @media screen and (color) {}
@ -148,6 +154,12 @@
: ^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/feature/input.css:2:1]
2 | @media only screen and (color) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/feature/input.css:2:1]
2 | @media only screen and (color) {}
@ -250,6 +262,12 @@
: ^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/feature/input.css:3:1]
3 | @media only screen and (min-width: 800px) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/feature/input.css:3:1]
3 | @media only screen and (min-width: 800px) {}
@ -376,6 +394,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/feature/input.css:4:1]
4 | @media screen and (min-width : 800px ) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/feature/input.css:4:1]
4 | @media screen and (min-width : 800px ) {}
@ -502,6 +526,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/feature/input.css:5:1]
5 | @media screen and (min-width: 800px) and (min-width: 800px) and (min-width: 800px) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/feature/input.css:5:1]
5 | @media screen and (min-width: 800px) and (min-width: 800px) and (min-width: 800px) {}
@ -784,6 +814,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/feature/input.css:6:1]
6 | @media screen and (min-width: 800px) and (min-width: 800px) and (min-width: 800px) and (min-width: 800px){}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/feature/input.css:6:1]
6 | @media screen and (min-width: 800px) and (min-width: 800px) and (min-width: 800px) and (min-width: 800px){}

View File

@ -46,6 +46,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:1:1]
1 | @media screen {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:1:1]
1 | @media screen {}
@ -100,6 +106,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:2:1]
2 | @media not screen {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:2:1]
2 | @media not screen {}
@ -154,6 +166,12 @@
: ^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:3:1]
3 | @media only screen {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:3:1]
3 | @media only screen {}
@ -202,6 +220,12 @@
: ^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:4:1]
4 | @media print, screen {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:4:1]
4 | @media print, screen {}
@ -214,6 +238,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:4:1]
4 | @media print, screen {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:4:1]
4 | @media print, screen {}
@ -262,6 +292,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:5:1]
5 | @media screen, all, print {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:5:1]
5 | @media screen, all, print {}
@ -274,6 +310,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:5:1]
5 | @media screen, all, print {}
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:5:1]
5 | @media screen, all, print {}
@ -286,6 +328,12 @@
: ^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:5:1]
5 | @media screen, all, print {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:5:1]
5 | @media screen, all, print {}
@ -340,6 +388,12 @@
: ^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:6:1]
6 | @media only screen, not all, only print {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:6:1]
6 | @media only screen, not all, only print {}
@ -358,6 +412,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:6:1]
6 | @media only screen, not all, only print {}
: ^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:6:1]
6 | @media only screen, not all, only print {}
@ -376,6 +436,12 @@
: ^^^^
`----
x MediaType
,-[$DIR/tests/fixture/rome/media/type/input.css:6:1]
6 | @media only screen, not all, only print {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/rome/media/type/input.css:6:1]
6 | @media only screen, not all, only print {}

View File

@ -52,6 +52,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/value/resolution/input.css:1:1]
1 | @media print and (min-resolution: 300dpi) {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/value/resolution/input.css:1:1]
1 | @media print and (min-resolution: 300dpi) {}
@ -178,6 +184,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/value/resolution/input.css:2:1]
2 | @media print and (min-resolution: 300dpcm) {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/value/resolution/input.css:2:1]
2 | @media print and (min-resolution: 300dpcm) {}
@ -304,6 +316,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/value/resolution/input.css:3:1]
3 | @media print and (min-resolution: 300dppx) {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/value/resolution/input.css:3:1]
3 | @media print and (min-resolution: 300dppx) {}
@ -430,6 +448,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/fixture/value/resolution/input.css:4:1]
4 | @media print and (min-resolution: 300x) {}
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/value/resolution/input.css:4:1]
4 | @media print and (min-resolution: 300x) {}

View File

@ -1,5 +1,5 @@
x Expected "("
x Expected Ident
,-[$DIR/tests/recovery/at-rule/import/no-semi/input.css:1:1]
1 | @import url('http://') :root {}
: ^

View File

@ -1,5 +1,5 @@
x Expected "("
x Expected ident (exclude the keywords 'only', 'not', 'and', 'or' and 'layer')
,-[$DIR/tests/recovery/at-rule/media/condition-and-or/input.css:1:1]
1 | @media screen and (min-width: 900px) or (min-width: 1200px) {}
: ^^

View File

@ -1,5 +1,5 @@
x Expected "("
x Expected ident (exclude the keywords 'only', 'not', 'and', 'or' and 'layer')
,-[$DIR/tests/recovery/at-rule/media/feature-value-missing/input.css:1:1]
1 | @media screen and (min-width: ) {}
: ^^^

View File

@ -5,7 +5,7 @@
: ^
`----
x Expected "("
x Expected ident (exclude the keywords 'only', 'not', 'and', 'or' and 'layer')
,-[$DIR/tests/recovery/at-rule/media/feature/input.css:1:1]
1 | @media screen and {}
: ^^^

View File

@ -0,0 +1,5 @@
@media only layer {
a {
color: red;
}
}

View File

@ -0,0 +1,210 @@
{
"type": "Stylesheet",
"span": {
"start": 1,
"end": 56,
"ctxt": 0
},
"rules": [
{
"type": "AtRule",
"span": {
"start": 1,
"end": 56,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 2,
"end": 7,
"ctxt": 0
},
"value": "media",
"raw": "media"
},
"prelude": {
"type": "ListOfComponentValues",
"span": {
"start": 7,
"end": 18,
"ctxt": 0
},
"children": [
{
"type": "PreservedToken",
"span": {
"start": 7,
"end": 8,
"ctxt": 0
},
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"type": "PreservedToken",
"span": {
"start": 8,
"end": 12,
"ctxt": 0
},
"token": {
"Ident": {
"value": "only",
"raw": "only"
}
}
},
{
"type": "PreservedToken",
"span": {
"start": 12,
"end": 13,
"ctxt": 0
},
"token": {
"WhiteSpace": {
"value": " "
}
}
},
{
"type": "PreservedToken",
"span": {
"start": 13,
"end": 18,
"ctxt": 0
},
"token": {
"Ident": {
"value": "layer",
"raw": "layer"
}
}
}
]
},
"block": {
"type": "SimpleBlock",
"span": {
"start": 19,
"end": 56,
"ctxt": 0
},
"name": "{",
"value": [
{
"type": "QualifiedRule",
"span": {
"start": 25,
"end": 54,
"ctxt": 0
},
"prelude": {
"type": "SelectorList",
"span": {
"start": 25,
"end": 26,
"ctxt": 0
},
"children": [
{
"type": "ComplexSelector",
"span": {
"start": 25,
"end": 26,
"ctxt": 0
},
"children": [
{
"type": "CompoundSelector",
"span": {
"start": 25,
"end": 26,
"ctxt": 0
},
"nestingSelector": null,
"typeSelector": {
"type": "TagNameSelector",
"span": {
"start": 25,
"end": 26,
"ctxt": 0
},
"name": {
"type": "WqName",
"span": {
"start": 25,
"end": 26,
"ctxt": 0
},
"prefix": null,
"value": {
"type": "Ident",
"span": {
"start": 25,
"end": 26,
"ctxt": 0
},
"value": "a",
"raw": "a"
}
}
},
"subclassSelectors": []
}
]
}
]
},
"block": {
"type": "SimpleBlock",
"span": {
"start": 27,
"end": 54,
"ctxt": 0
},
"name": "{",
"value": [
{
"type": "Declaration",
"span": {
"start": 37,
"end": 47,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 37,
"end": 42,
"ctxt": 0
},
"value": "color",
"raw": "color"
},
"value": [
{
"type": "Ident",
"span": {
"start": 44,
"end": 47,
"ctxt": 0
},
"value": "red",
"raw": "red"
}
],
"important": null
}
]
}
}
]
}
}
]
}

View File

@ -0,0 +1,6 @@
x Expected ident (exclude the keywords 'only', 'not', 'and', 'or' and 'layer')
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^^^^^
`----

View File

@ -0,0 +1,208 @@
x Stylesheet
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | ,-> @media only layer {
2 | | a {
3 | | color: red;
4 | | }
5 | `-> }
`----
x Rule
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | ,-> @media only layer {
2 | | a {
3 | | color: red;
4 | | }
5 | `-> }
`----
x AtRule
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | ,-> @media only layer {
2 | | a {
3 | | color: red;
4 | | }
5 | `-> }
`----
x AtRuleName
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^^^^^
`----
x Ident
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^^^^^
`----
x ComponentValue
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^
`----
x WhiteSpace { value: Atom(' ' type=inline) }
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^
`----
x ComponentValue
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^^^^
`----
x Ident { value: Atom('only' type=static), raw: Atom('only' type=static) }
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^^^^
`----
x ComponentValue
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^
`----
x WhiteSpace { value: Atom(' ' type=inline) }
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^
`----
x ComponentValue
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^^^^^
`----
x Ident { value: Atom('layer' type=inline), raw: Atom('layer' type=inline) }
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | @media only layer {
: ^^^^^
`----
x SimpleBlock
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:1:1]
1 | ,-> @media only layer {
2 | | a {
3 | | color: red;
4 | | }
5 | `-> }
`----
x ComponentValue
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | ,-> a {
3 | | color: red;
4 | `-> }
`----
x Rule
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | ,-> a {
3 | | color: red;
4 | `-> }
`----
x QualifiedRule
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | ,-> a {
3 | | color: red;
4 | `-> }
`----
x SelectorList
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | a {
: ^
`----
x ComplexSelector
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | a {
: ^
`----
x CompoundSelector
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | a {
: ^
`----
x TypeSelector
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | a {
: ^
`----
x TagNameSelector
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | a {
: ^
`----
x WqName
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | a {
: ^
`----
x Ident
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | a {
: ^
`----
x SimpleBlock
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:2:5]
2 | ,-> a {
3 | | color: red;
4 | `-> }
`----
x ComponentValue
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:3:9]
3 | color: red;
: ^^^^^^^^^^
`----
x StyleBlock
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:3:9]
3 | color: red;
: ^^^^^^^^^^
`----
x Declaration
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:3:9]
3 | color: red;
: ^^^^^^^^^^
`----
x DeclarationName
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:3:9]
3 | color: red;
: ^^^^^
`----
x Ident
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:3:9]
3 | color: red;
: ^^^^^
`----
x ComponentValue
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:3:9]
3 | color: red;
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/at-rule/media/media-type/input.css:3:9]
3 | color: red;
: ^^^
`----

View File

@ -53,6 +53,12 @@
: ^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/at-rule/media/wrong-stylesheet/input.css:1:1]
1 | @media print {
: ^^^^^
`----
x Ident
,-[$DIR/tests/recovery/at-rule/media/wrong-stylesheet/input.css:1:1]
1 | @media print {

View File

@ -44,6 +44,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/at-rule/no-semi/input.css:1:1]
1 | @media screen {@content}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/at-rule/no-semi/input.css:1:1]
1 | @media screen {@content}

View File

@ -427,6 +427,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:5:1]
5 | @media screen and (min-width:0\0) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:5:1]
5 | @media screen and (min-width:0\0) {}
@ -1099,6 +1105,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:16:1]
16 | @media \\0 screen {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:16:1]
16 | @media \\0 screen {}
@ -1147,6 +1159,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:18:1]
18 | @media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) { .selector {} }
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:18:1]
18 | @media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) { .selector {} }
@ -1663,6 +1681,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:26:1]
26 | @media \0 all {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:26:1]
26 | @media \0 all {}
@ -2077,6 +2101,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:32:1]
32 | @media screen and (-moz-images-in-menus:0) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:32:1]
32 | @media screen and (-moz-images-in-menus:0) {}
@ -2185,6 +2215,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:34:1]
34 | @media screen and (min--moz-device-pixel-ratio:0) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:34:1]
34 | @media screen and (min--moz-device-pixel-ratio:0) {}
@ -2455,6 +2491,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:38:1]
38 | @media all and (min--moz-device-pixel-ratio:0) and (min-resolution: .001dpcm) {}
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:38:1]
38 | @media all and (min--moz-device-pixel-ratio:0) and (min-resolution: .001dpcm) {}
@ -2641,6 +2683,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:39:1]
39 | @media all and (-moz-images-in-menus:0) and (min-resolution: .001dpcm) {}
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:39:1]
39 | @media all and (-moz-images-in-menus:0) and (min-resolution: .001dpcm) {}
@ -2827,6 +2875,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:41:1]
41 | @media all and (min--moz-device-pixel-ratio:0) { @media (min-width: 0px) {} }
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:41:1]
41 | @media all and (min--moz-device-pixel-ratio:0) { @media (min-width: 0px) {} }
@ -3055,6 +3109,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:42:1]
42 | @media all and (-moz-images-in-menus:0) { @media (min-width: 0px) {} }
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:42:1]
42 | @media all and (-moz-images-in-menus:0) { @media (min-width: 0px) {} }
@ -4411,6 +4471,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:60:1]
60 | @media all and (min--moz-device-pixel-ratio:0) and (min-resolution: 3e1dpcm) {}
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:60:1]
60 | @media all and (min--moz-device-pixel-ratio:0) and (min-resolution: 3e1dpcm) {}
@ -11041,6 +11107,12 @@
: ^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:182:1]
182 | @media screen\9 {}
: ^^^^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:182:1]
182 | @media screen\9 {}
@ -11089,6 +11161,12 @@
: ^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:184:1]
184 | @media \0screen\,screen\9 {}
: ^^^^^^^^^^^^^^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:184:1]
184 | @media \0screen\,screen\9 {}
@ -11137,6 +11215,12 @@
: ^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:186:1]
186 | @media \0screen {}
: ^^^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:186:1]
186 | @media \0screen {}
@ -11185,6 +11269,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:188:1]
188 | @media screen and (min-width:0\0) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:188:1]
188 | @media screen and (min-width:0\0) {}
@ -11587,6 +11677,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:194:1]
194 | @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:194:1]
194 | @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {}
@ -11755,6 +11851,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:196:1]
196 | @media screen { @media (min-width: 0px) {} }
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:196:1]
196 | @media screen { @media (min-width: 0px) {} }
@ -12739,6 +12841,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:211:1]
211 | @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {}
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:211:1]
211 | @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {}
@ -12817,6 +12925,12 @@
: ^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:211:1]
211 | @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {}
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:211:1]
211 | @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {}
@ -13297,6 +13411,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:217:1]
217 | @media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) { .selector {} }
: ^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:217:1]
217 | @media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) { .selector {} }
@ -14089,6 +14209,12 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:228:1]
228 | @media screen and (min-width:0\0) {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:228:1]
228 | @media screen and (min-width:0\0) {}
@ -14215,6 +14341,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:230:1]
230 | @media screen { @media (min-width: 0px) {} }
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:230:1]
230 | @media screen { @media (min-width: 0px) {} }
@ -15109,6 +15241,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/hacks/input.css:241:1]
241 | @media \\0 screen {}
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/hacks/input.css:241:1]
241 | @media \\0 screen {}

View File

@ -582,6 +582,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/styled-jsx/1/input.css:14:1]
14 | @media screen {
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/styled-jsx/1/input.css:14:1]
14 | @media screen {
@ -835,6 +841,12 @@
: ^^^^^^
`----
x MediaType
,-[$DIR/tests/recovery/styled-jsx/1/input.css:20:1]
20 | @media screen {
: ^^^^^^
`----
x Ident
,-[$DIR/tests/recovery/styled-jsx/1/input.css:20:1]
20 | @media screen {

View File

@ -657,11 +657,15 @@ define!({
pub struct MediaQuery {
pub span: Span,
pub modifier: Option<Ident>,
pub media_type: Option<Ident>,
pub media_type: Option<MediaType>,
pub keyword: Option<Ident>,
pub condition: Option<MediaConditionType>,
}
pub enum MediaType {
Ident(Ident),
}
pub enum MediaConditionType {
All(MediaCondition),
WithoutOr(MediaConditionWithoutOr),