allow units to begin with escape sequences

This commit is contained in:
ConnorSkees 2020-05-16 18:54:42 -04:00
parent d4f67b5ed9
commit f3e7abdaba
2 changed files with 11 additions and 1 deletions

View File

@ -647,7 +647,7 @@ impl Value {
}; };
let unit = if let Some(tok) = toks.peek() { let unit = if let Some(tok) = toks.peek() {
match tok.kind { match tok.kind {
'a'..='z' | 'A'..='Z' | '_' => { 'a'..='z' | 'A'..='Z' | '_' | '\\' => {
let u = match eat_ident_no_interpolation(toks, true) { let u = match eat_ident_no_interpolation(toks, true) {
Ok(v) => v, Ok(v) => v,
Err(e) => return Some(Err(e)), Err(e) => return Some(Err(e)),

View File

@ -74,6 +74,16 @@ test!(
"a {\n color: 1px-2px;\n}\n", "a {\n color: 1px-2px;\n}\n",
"a {\n color: -1px;\n}\n" "a {\n color: -1px;\n}\n"
); );
test!(
unit_starts_with_escape_sequence,
"a {\n color: 1\\9;\n}\n",
"a {\n color: 1\\9 ;\n}\n"
);
test!(
unit_fn_starts_with_escape_sequence,
"a {\n color: unit(1\\9);\n}\n",
"a {\n color: \"\\\\9 \";\n}\n"
);
error!( error!(
display_single_mul, display_single_mul,
"a {\n color: 1rem * 1px;\n}\n", "Error: 1rem*px isn't a valid CSS value." "a {\n color: 1rem * 1px;\n}\n", "Error: 1rem*px isn't a valid CSS value."