Navigation Menu

Skip to content

Commit

Permalink
_operator is used for seperating multiple values for a property (ie. …
Browse files Browse the repository at this point in the history
…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
fracmak committed Nov 14, 2012
1 parent e0be226 commit ebf3f4a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/css/Parser.js
Expand Up @@ -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();
}
Expand Down Expand Up @@ -1506,7 +1509,7 @@ Parser.prototype = function(){
return result;
},

_expr: function(){
_expr: function(inFunction){
/*
* expr
* : term [ operator term ]*
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ebf3f4a

Please sign in to comment.