diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js index 3e2fe36af..ec5d0db06 100644 --- a/lib/less/parser/parser.js +++ b/lib/less/parser/parser.js @@ -1619,21 +1619,42 @@ var Parser = function Parser(context, imports, fileInfo) { } }, condition: function () { + var result, logical, next; + function or() { + return parserInput.$str("or"); + } + + result = this.conditionAnd(this); + if (!result) { + return ; + } + logical = or(); + if (logical) { + next = this.condition(); + if (next) { + result = new(tree.Condition)(logical, result, next); + } else { + return ; + } + } + return result; + }, + conditionAnd: function () { var result, logical, next; function insideCondition(me) { return me.negatedCondition() || me.parenthesisCondition(); } - function logicalOperator() { - return parserInput.$str("and") || parserInput.$str("or"); + function and() { + return parserInput.$str("and"); } result = insideCondition(this); if (!result) { return ; } - logical = logicalOperator(); + logical = and(); if (logical) { - next = this.condition(); + next = this.conditionAnd(); if (next) { result = new(tree.Condition)(logical, result, next); } else { diff --git a/test/css/mixins-guards.css b/test/css/mixins-guards.css index dfbec824a..3b749af12 100644 --- a/test/css/mixins-guards.css +++ b/test/css/mixins-guards.css @@ -185,15 +185,27 @@ parenthesisNot: negated once middle; } #orderOfEvaluation-false-false-true { + no-parenthesis: evaluated true 1a; + no-parenthesis: evaluated true 1b; + no-parenthesis: evaluated true 1d; no-parenthesis: evaluated true 3; + no-parenthesis: evaluated true 4; with-parenthesis: evaluated true; } #orderOfEvaluation-false-false-false { - orderOfEvaluation: evaluated false; + no-parenthesis: evaluated true 2a; + no-parenthesis: evaluated true 2b; + no-parenthesis: evaluated true 2c; } #orderOfEvaluation-true-true-false { - no-parenthesis: evaluated true 1; - no-parenthesis: evaluated true 2; + no-parenthesis: evaluated true 1a; + no-parenthesis: evaluated true 1b; + no-parenthesis: evaluated true 1c; + no-parenthesis: evaluated true 1d; + no-parenthesis: evaluated true 1e; + no-parenthesis: evaluated true 2a; + no-parenthesis: evaluated true 2b; + no-parenthesis: evaluated true 2c; no-parenthesis: evaluated true 4; with-parenthesis: evaluated true; } diff --git a/test/less/mixins-guards.less b/test/less/mixins-guards.less index cf37c011e..031f1187e 100644 --- a/test/less/mixins-guards.less +++ b/test/less/mixins-guards.less @@ -312,10 +312,28 @@ } .orderOfEvaluation(@a1, @a2, @a3) when ((@a1) and (@a2) or (@a3)) { - no-parenthesis: evaluated true 1; + no-parenthesis: evaluated true 1a; +} +.orderOfEvaluation(@a1, @a2, @a3) when ((@a3) or (@a1) and (@a2)) { + no-parenthesis: evaluated true 1b; +} +.orderOfEvaluation(@a1, @a2, @a3) when ((@a1) and ((@a2) or (@a3))) { + no-parenthesis: evaluated true 1c; +} +.orderOfEvaluation(@a1, @a2, @a3) when (@a3), (@a1) and (@a2) { + no-parenthesis: evaluated true 1d; +} +.orderOfEvaluation(@a1, @a2, @a3) when (((@a3) or (@a1)) and (@a2)) { + no-parenthesis: evaluated true 1e; } .orderOfEvaluation(@a1, @a2, @a3) when ((@a1) and (@a2) or not (@a3)) { - no-parenthesis: evaluated true 2; + no-parenthesis: evaluated true 2a; +} +.orderOfEvaluation(@a1, @a2, @a3) when (not (@a3) or (@a1) and (@a2)) { + no-parenthesis: evaluated true 2b; +} +.orderOfEvaluation(@a1, @a2, @a3) when not (@a3), (@a1) and (@a2) { + no-parenthesis: evaluated true 2c; } .orderOfEvaluation(@a1, @a2, @a3) when (not (@a1) and (@a2) or (@a3)) { no-parenthesis: evaluated true 3;