Permalink
Browse files

_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
  • Loading branch information...
1 parent e0be226 commit ebf3f4a2ff26f06a88952dc21bd27145da7dccc1 @fracmak committed Nov 14, 2012
Showing with 11 additions and 8 deletions.
  1. +11 −8 src/css/Parser.js
View
@@ -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

0 comments on commit ebf3f4a

Please sign in to comment.