From 626d7f15231a080c796a31f1479cd0f6ee761bd6 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Sat, 24 Dec 2011 13:32:13 +0100 Subject: [PATCH] additional support for mixin guards --- lib/less/parser.js | 6 +++--- lib/less/tree/keyword.js | 7 ++++++- lib/less/tree/mixin.js | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/less/parser.js b/lib/less/parser.js index afa98e39..238e5fd5 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -1139,10 +1139,10 @@ less.Parser = function Parser(env) { } }, condition: function () { - var a, op, index = i; - if (a = $(this.addition)) { + var a, b, op, index = i; + if (a = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) { if (op = $(/^[<=>]/)) { - if (b = $(this.addition)) { + if (b = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) { return new(tree.Condition)(op, a, b, index); } } diff --git a/lib/less/tree/keyword.js b/lib/less/tree/keyword.js index 01635b22..7ac26dbc 100644 --- a/lib/less/tree/keyword.js +++ b/lib/less/tree/keyword.js @@ -3,7 +3,12 @@ tree.Keyword = function (value) { this.value = value }; tree.Keyword.prototype = { eval: function () { return this }, - toCSS: function () { return this.value } + toCSS: function () { return this.value }, + compare: function (other) { + if (other instanceof tree.Keyword) { + return other.value === this.value ? 0 : 1; + } + } }; })(require('../tree')); diff --git a/lib/less/tree/mixin.js b/lib/less/tree/mixin.js index bc6807c0..ad92280d 100644 --- a/lib/less/tree/mixin.js +++ b/lib/less/tree/mixin.js @@ -98,7 +98,7 @@ tree.mixin.Definition.prototype = { if (argsLength < this.required) { return false } if ((this.required > 0) && (argsLength > this.params.length)) { return false } if (this.condition && !this.condition.eval({ - frames: [this.evalParams(env, args)] + frames: [this.evalParams(env, args)].concat(env.frames) })) { return false } len = Math.min(argsLength, this.arity);