change negation operators to be more cssy

This commit is contained in:
Alexis Sellier
2012-01-03 22:41:14 +01:00
parent a40a9ee4db
commit d8441445a5
4 changed files with 13 additions and 7 deletions

View File

@@ -1171,17 +1171,17 @@ less.Parser = function Parser(env) {
condition: function () {
var a, b, c, op, index = i, negate = false;
if ($(/^not/)) { negate = true }
expect('(');
if ($('!')) { negate = true }
if (a = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) {
if (op = $(/^(?:>=|=<|\!=|[<=>])/)) {
if (op = $(/^(?:>=|=<|\^=|[<=>])/)) {
if (b = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) {
c = new(tree.Condition)(op, a, b, index);
} else {
error('expected expression');
}
} else {
c = new(tree.Condition)(negate ? '!=' : '=', a, new(tree.Keyword)('true'), index);
c = new(tree.Condition)(negate ? '^=' : '=', a, new(tree.Keyword)('true'), index);
}
expect(')');
return $(/^and/) ? new(tree.Condition)('and', c, $(this.condition)) : c;

View File

@@ -28,9 +28,9 @@ tree.Condition.prototype.eval = function (env) {
index: i };
}
switch (result) {
case -1: return this.op === '<' || this.op === '=<' || this.op === '!=';
case -1: return this.op === '<' || this.op === '=<' || this.op === '^=';
case 0: return this.op === '=' || this.op === '>=' || this.op === '=<';
case 1: return this.op === '>' || this.op === '>=' || this.op === '!=';
case 1: return this.op === '>' || this.op === '>=' || this.op === '^=';
}
}
};