зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1706223 - Fix whitespace handling in clamp() parsing. r=xidorn
We should just restore the state when seeing whitespace and an unknown token like when we do when finding any other token a few lines below. This is not an issue for most callers (it's only an issue for clamp()) because the other callers use either `parse_comma_separated()` (for min/max), or `parse_nested_block()` (for parens / nested calc()). Both of those functions restrict the input in such a way that is_exhausted returns true (a few lines above) and thus we parse successfully. Differential Revision: https://phabricator.services.mozilla.com/D112681
This commit is contained in:
Родитель
8084c55348
Коммит
8814b4ab14
|
@ -373,9 +373,9 @@ impl CalcNode {
|
|||
rhs.negate();
|
||||
sum.push(rhs);
|
||||
},
|
||||
ref t => {
|
||||
let t = t.clone();
|
||||
return Err(input.new_unexpected_token_error(t));
|
||||
_ => {
|
||||
input.reset(&start);
|
||||
break;
|
||||
},
|
||||
}
|
||||
},
|
||||
|
|
|
@ -22,6 +22,10 @@ function test_length_equals(value, expected) {
|
|||
test_length_equals('clamp(10px, 20px, 30px)', '20px');
|
||||
test_length_equals('clamp(10px, 5px, 30px)', '10px');
|
||||
test_length_equals('clamp(10px, 35px, 30px)', '30px');
|
||||
test_length_equals('clamp(10px, 35px , 30px)', '30px');
|
||||
test_length_equals('clamp(10px, 35px /*foo*/, 30px)', '30px');
|
||||
test_length_equals('clamp(10px /* foo */ , 35px, 30px)', '30px');
|
||||
test_length_equals('clamp(10px , 35px, 30px)', '30px');
|
||||
|
||||
// clamp(MIN, VAL, MAX) is identical to max(MIN, min(VAL, MAX)),
|
||||
// so MIN wins over MAX if they are in the wrong order.
|
||||
|
|
Загрузка…
Ссылка в новой задаче