mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
reworked guard comparison
This commit is contained in:
@@ -14,34 +14,20 @@ tree.Condition.prototype = {
|
||||
this.rvalue = visitor.visit(this.rvalue);
|
||||
},
|
||||
eval: function (env) {
|
||||
var a = this.lvalue.eval(env),
|
||||
b = this.rvalue.eval(env);
|
||||
|
||||
var i = this.index, result;
|
||||
|
||||
result = (function (op) {
|
||||
var result = (function (op, a, b) {
|
||||
switch (op) {
|
||||
case 'and':
|
||||
return a && b;
|
||||
case 'or':
|
||||
return a || b;
|
||||
case 'and': return a && b;
|
||||
case 'or': return a || b;
|
||||
default:
|
||||
if (a.compare) {
|
||||
result = a.compare(b);
|
||||
} else if (b.compare) {
|
||||
result = b.compare(a);
|
||||
} else {
|
||||
throw { type: "Type",
|
||||
message: "Unable to perform comparison",
|
||||
index: i };
|
||||
}
|
||||
switch (result) {
|
||||
switch (tree.compare(a, b)) {
|
||||
case -1: return op === '<' || op === '=<' || op === '<=';
|
||||
case 0: return op === '=' || op === '>=' || op === '=<' || op === '<=';
|
||||
case 1: return op === '>' || op === '>=';
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
})(this.op);
|
||||
}) (this.op, this.lvalue.eval(env), this.rvalue.eval(env));
|
||||
|
||||
return this.negate ? !result : result;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user