From ebf3f4a2ff26f06a88952dc21bd27145da7dccc1 Mon Sep 17 00:00:00 2001 From: Jay Merrifield Date: Tue, 13 Nov 2012 23:43:55 -0500 Subject: [PATCH] _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 --- src/css/Parser.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/css/Parser.js b/src/css/Parser.js index 1a68d222..310151bd 100644 --- a/src/css/Parser.js +++ b/src/css/Parser.js @@ -708,18 +708,21 @@ Parser.prototype = function(){ }); }, - _operator: function(){ + _operator: function(inFunction){ /* - * operator - * : '/' S* | ',' S* | '+' S* | '*' S* | '-' S* /( empty )/ + * operator (outside function) + * : '/' S* | ',' S* | /( empty )/ + * operator (inside function) + * : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/ * ; */ var tokenStream = this._tokenStream, token = null; - if (tokenStream.match([Tokens.SLASH, Tokens.COMMA, Tokens.PLUS, Tokens.STAR, Tokens.MINUS])){ + if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) || + (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){ token = tokenStream.token(); this._readWhitespace(); } @@ -1506,7 +1509,7 @@ Parser.prototype = function(){ return result; }, - _expr: function(){ + _expr: function(inFunction){ /* * expr * : term [ operator term ]* @@ -1525,8 +1528,8 @@ Parser.prototype = function(){ values.push(value); do { - operator = this._operator(); - + operator = this._operator(inFunction); + //if there's an operator, keep building up the value parts if (operator){ values.push(operator); @@ -1662,7 +1665,7 @@ Parser.prototype = function(){ if (tokenStream.match(Tokens.FUNCTION)){ functionText = tokenStream.token().value; this._readWhitespace(); - expr = this._expr(); + expr = this._expr(true); functionText += expr; //START: Horrible hack in case it's an IE filter