more robustly handle - as start of identifier
This commit is contained in:
parent
38c45129d9
commit
4607163a62
@ -30,6 +30,7 @@ a special parser for plain css
|
|||||||
@forward (~400 tests)
|
@forward (~400 tests)
|
||||||
@keyframes (~30 tests)
|
@keyframes (~30 tests)
|
||||||
@supports (~128 tests)
|
@supports (~128 tests)
|
||||||
|
aribtrary control flow in @function and @mixin
|
||||||
```
|
```
|
||||||
|
|
||||||
To run the official test suite,
|
To run the official test suite,
|
||||||
|
@ -245,12 +245,6 @@ fn eat_op<I: Iterator<Item = IntermediateValue>>(
|
|||||||
Op::Minus => {
|
Op::Minus => {
|
||||||
if devour_whitespace(iter) || !last_was_whitespace {
|
if devour_whitespace(iter) || !last_was_whitespace {
|
||||||
let right = single_value(iter, scope, super_selector, op.span)?;
|
let right = single_value(iter, scope, super_selector, op.span)?;
|
||||||
if !last_was_whitespace && right.node == Value::Null {
|
|
||||||
space_separated.push(
|
|
||||||
right.map_node(|_| Value::Ident("-null".to_string(), QuoteKind::None)),
|
|
||||||
);
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
if let Some(left) = space_separated.pop() {
|
if let Some(left) = space_separated.pop() {
|
||||||
space_separated.push(Spanned {
|
space_separated.push(Spanned {
|
||||||
node: Value::BinaryOp(Box::new(left.node), op.node, Box::new(right.node)),
|
node: Value::BinaryOp(Box::new(left.node), op.node, Box::new(right.node)),
|
||||||
@ -261,12 +255,6 @@ fn eat_op<I: Iterator<Item = IntermediateValue>>(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let right = single_value(iter, scope, super_selector, op.span)?;
|
let right = single_value(iter, scope, super_selector, op.span)?;
|
||||||
if right.node == Value::Null {
|
|
||||||
space_separated.push(
|
|
||||||
right.map_node(|_| Value::Ident("-null".to_string(), QuoteKind::None)),
|
|
||||||
);
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
space_separated.push(right.map_node(|n| Value::UnaryOp(op.node, Box::new(n))));
|
space_separated.push(right.map_node(|n| Value::UnaryOp(op.node, Box::new(n))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -601,6 +589,11 @@ impl Value {
|
|||||||
Some(v) => (v.kind, v.pos()),
|
Some(v) => (v.kind, v.pos()),
|
||||||
None => panic!("unexpected eof"),
|
None => panic!("unexpected eof"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let next_is_hypen = |toks: &mut PeekMoreIterator<I>| {
|
||||||
|
toks.peek_forward(1).is_some()
|
||||||
|
&& matches!(toks.peek().unwrap().kind, '-' | '_' | 'a'..='z' | 'A'..='Z')
|
||||||
|
};
|
||||||
match kind {
|
match kind {
|
||||||
',' => {
|
',' => {
|
||||||
toks.next();
|
toks.next();
|
||||||
@ -689,7 +682,8 @@ impl Value {
|
|||||||
_ if kind.is_ascii_alphabetic()
|
_ if kind.is_ascii_alphabetic()
|
||||||
|| kind == '_'
|
|| kind == '_'
|
||||||
|| kind == '\\'
|
|| kind == '\\'
|
||||||
|| (!kind.is_ascii() && !kind.is_control()) =>
|
|| (!kind.is_ascii() && !kind.is_control())
|
||||||
|
|| (kind == '-' && next_is_hypen(toks)) =>
|
||||||
{
|
{
|
||||||
Self::ident(toks, scope, super_selector)
|
Self::ident(toks, scope, super_selector)
|
||||||
}
|
}
|
||||||
|
@ -28,3 +28,8 @@ test!(
|
|||||||
"a {\n color: [null null null];\n}\n",
|
"a {\n color: [null null null];\n}\n",
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
negative_null_in_var,
|
||||||
|
"a {\n $x: null;\n color: -$x;\n}\n",
|
||||||
|
"a {\n color: -;\n}\n"
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user