additional support for mixin guards

This commit is contained in:
Alexis Sellier
2011-12-24 13:32:13 +01:00
parent 17137c1a70
commit 626d7f1523
3 changed files with 10 additions and 5 deletions

View File

@@ -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);
}
}

View File

@@ -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'));

View File

@@ -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);