allow units beginning with a single -
This commit is contained in:
parent
cb046f7be7
commit
9b9946c0ee
@ -476,6 +476,22 @@ impl<'a> Parser<'a> {
|
|||||||
span = span.merge(u.span);
|
span = span.merge(u.span);
|
||||||
Unit::from(u.node)
|
Unit::from(u.node)
|
||||||
}
|
}
|
||||||
|
'-' => {
|
||||||
|
if let Some(Token { kind, .. }) = self.toks.peek_next().cloned() {
|
||||||
|
self.toks.reset_cursor();
|
||||||
|
if matches!(kind, 'a'..='z' | 'A'..='Z' | '_' | '\\' | '\u{7f}'..=std::char::MAX)
|
||||||
|
{
|
||||||
|
let u = self.parse_identifier_no_interpolation(true)?;
|
||||||
|
span = span.merge(u.span);
|
||||||
|
Unit::from(u.node)
|
||||||
|
} else {
|
||||||
|
Unit::None
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.toks.reset_cursor();
|
||||||
|
Unit::None
|
||||||
|
}
|
||||||
|
}
|
||||||
'%' => {
|
'%' => {
|
||||||
span = span.merge(self.toks.next().unwrap().pos());
|
span = span.merge(self.toks.next().unwrap().pos());
|
||||||
Unit::Percent
|
Unit::Percent
|
||||||
|
@ -127,6 +127,31 @@ test!(
|
|||||||
"a {\n color: unit((1 / 1in) * 1in);\n}\n",
|
"a {\n color: unit((1 / 1in) * 1in);\n}\n",
|
||||||
"a {\n color: \"\";\n}\n"
|
"a {\n color: \"\";\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
unit_begins_with_single_hyphen,
|
||||||
|
"a {\n color: unit(1-em);\n}\n",
|
||||||
|
"a {\n color: \"-em\";\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
unit_begins_with_two_hyphens,
|
||||||
|
"a {\n color: 1--em;\n}\n",
|
||||||
|
"a {\n color: 1 --em;\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
unit_begins_with_escape_sequence,
|
||||||
|
"a {\n color: unit(1\\65);\n}\n",
|
||||||
|
"a {\n color: \"e\";\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
unit_begins_with_escape_sequence_followed_by_space_and_hyphen,
|
||||||
|
"a {\n color: unit(1\\65 -);\n}\n",
|
||||||
|
"a {\n color: \"e-\";\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
unit_begins_with_single_hyphen_followed_by_escape_sequence,
|
||||||
|
"a {\n color: unit(1-\\65);\n}\n",
|
||||||
|
"a {\n color: \"-e\";\n}\n"
|
||||||
|
);
|
||||||
error!(
|
error!(
|
||||||
display_single_div_with_none_numerator,
|
display_single_div_with_none_numerator,
|
||||||
"a {\n color: (1 / 1em);\n}\n", "Error: 1em^-1 isn't a valid CSS value."
|
"a {\n color: (1 / 1em);\n}\n", "Error: 1em^-1 isn't a valid CSS value."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user