Skip to content

Commit ebf3f4a

Browse files
committed
_operator is used for seperating multiple values for a property (ie. box-shadow: 10px 10px 0, 2px 2px 0) as well as for mathematical operators inside functions. Since functions are the only place mathematical operators are allowed, we now pass in a boolean to distinguish which token is acceptable to not accidentally treat -10px -10px as an equation
1 parent e0be226 commit ebf3f4a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/css/Parser.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -708,18 +708,21 @@ Parser.prototype = function(){
708708
});
709709
},
710710

711-
_operator: function(){
711+
_operator: function(inFunction){
712712

713713
/*
714-
* operator
715-
* : '/' S* | ',' S* | '+' S* | '*' S* | '-' S* /( empty )/
714+
* operator (outside function)
715+
* : '/' S* | ',' S* | /( empty )/
716+
* operator (inside function)
717+
* : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/
716718
* ;
717719
*/
718720

719721
var tokenStream = this._tokenStream,
720722
token = null;
721723

722-
if (tokenStream.match([Tokens.SLASH, Tokens.COMMA, Tokens.PLUS, Tokens.STAR, Tokens.MINUS])){
724+
if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
725+
(inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){
723726
token = tokenStream.token();
724727
this._readWhitespace();
725728
}
@@ -1506,7 +1509,7 @@ Parser.prototype = function(){
15061509
return result;
15071510
},
15081511

1509-
_expr: function(){
1512+
_expr: function(inFunction){
15101513
/*
15111514
* expr
15121515
* : term [ operator term ]*
@@ -1525,8 +1528,8 @@ Parser.prototype = function(){
15251528
values.push(value);
15261529

15271530
do {
1528-
operator = this._operator();
1529-
1531+
operator = this._operator(inFunction);
1532+
15301533
//if there's an operator, keep building up the value parts
15311534
if (operator){
15321535
values.push(operator);
@@ -1662,7 +1665,7 @@ Parser.prototype = function(){
16621665
if (tokenStream.match(Tokens.FUNCTION)){
16631666
functionText = tokenStream.token().value;
16641667
this._readWhitespace();
1665-
expr = this._expr();
1668+
expr = this._expr(true);
16661669
functionText += expr;
16671670

16681671
//START: Horrible hack in case it's an IE filter

0 commit comments

Comments
 (0)