allow idents to begin with hyphen
This commit is contained in:
parent
9e38fbc747
commit
5bbf10b05f
@ -165,12 +165,10 @@ impl Value {
|
||||
))
|
||||
}
|
||||
}
|
||||
'+' | '-' | '*' | '%' => {
|
||||
'+' | '*' | '%' => {
|
||||
let op = match next.kind {
|
||||
'+' => Op::Plus,
|
||||
'-' => Op::Minus,
|
||||
'*' => Op::Mul,
|
||||
'/' => Op::Div,
|
||||
'%' => Op::Rem,
|
||||
_ => unsafe { std::hint::unreachable_unchecked() },
|
||||
};
|
||||
@ -215,6 +213,28 @@ impl Value {
|
||||
return Err("Expected \"important\".".into());
|
||||
}
|
||||
}
|
||||
'-' => {
|
||||
toks.next();
|
||||
if devour_whitespace(toks) {
|
||||
let right = Self::from_tokens(toks, scope, super_selector)?;
|
||||
Ok(Value::BinaryOp(Box::new(left), Op::Minus, Box::new(right)))
|
||||
} else {
|
||||
let right = Self::from_tokens(toks, scope, super_selector)?;
|
||||
if let Value::List(mut v, ListSeparator::Space, ..) = right {
|
||||
let mut v2 = vec![left];
|
||||
let val = v.remove(0);
|
||||
v2.push((-val)?);
|
||||
v2.extend(v);
|
||||
Ok(Value::List(v2, ListSeparator::Space, Brackets::None))
|
||||
} else {
|
||||
Ok(Value::List(
|
||||
vec![left, (-right)?],
|
||||
ListSeparator::Space,
|
||||
Brackets::None,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
'/' => {
|
||||
toks.next();
|
||||
match toks.peek().unwrap().kind {
|
||||
|
@ -71,8 +71,19 @@ test!(
|
||||
"@charset \"UTF-8\";\na {\n color: red😁;\n}\n"
|
||||
);
|
||||
test!(
|
||||
#[ignore]
|
||||
no_space_before_style,
|
||||
"a {\n color:red\n}\n",
|
||||
"a {\n color: red;\n}\n"
|
||||
);
|
||||
test!(
|
||||
does_not_combine_idents_with_leading_hyphen,
|
||||
"a {\n color: a -b;\n}\n"
|
||||
);
|
||||
test!(
|
||||
does_not_combine_idents_with_leading_hyphen_list,
|
||||
"a {\n color: a -b c;\n}\n"
|
||||
);
|
||||
test!(
|
||||
does_not_combine_idents_with_leading_hyphen_all,
|
||||
"a {\n color: -a -b -c;\n}\n"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user