mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 19:34:27 -05:00
made until less parenful as well
This commit is contained in:
37
lib/nodes.js
37
lib/nodes.js
@@ -141,9 +141,12 @@
|
||||
if (func(child) === false) {
|
||||
return false;
|
||||
}
|
||||
return child instanceof Base && (crossScope || !(child instanceof Code)) ? child.traverseChildren(crossScope, func) : undefined;
|
||||
return crossScope || !(child instanceof Code) ? child.traverseChildren(crossScope, func) : undefined;
|
||||
});
|
||||
};
|
||||
Base.prototype.invert = function() {
|
||||
return new Op('!', this);
|
||||
};
|
||||
Base.prototype.children = [];
|
||||
Base.prototype.unwrap = THIS;
|
||||
Base.prototype.isStatement = NO;
|
||||
@@ -1271,13 +1274,7 @@
|
||||
While = (function() {
|
||||
return function While(condition, opts) {
|
||||
While.__super__.constructor.call(this);
|
||||
if (((opts != null) ? opts.invert : undefined)) {
|
||||
if (condition instanceof Op) {
|
||||
condition = new Parens(condition);
|
||||
}
|
||||
condition = new Op('!', condition);
|
||||
}
|
||||
this.condition = condition;
|
||||
this.condition = ((opts != null) ? opts.invert : undefined) ? condition.invert() : condition;
|
||||
this.guard = ((opts != null) ? opts.guard : undefined);
|
||||
return this;
|
||||
};
|
||||
@@ -1362,10 +1359,6 @@
|
||||
Op.prototype.isUnary = function() {
|
||||
return !this.second;
|
||||
};
|
||||
Op.prototype.isInvertible = function() {
|
||||
var _ref2;
|
||||
return ('===' === (_ref2 = this.operator) || '!==' === _ref2);
|
||||
};
|
||||
Op.prototype.isComplex = function() {
|
||||
return this.operator !== '!' || this.first.isComplex();
|
||||
};
|
||||
@@ -1377,7 +1370,11 @@
|
||||
return include(this.CHAINABLE, this.operator);
|
||||
};
|
||||
Op.prototype.invert = function() {
|
||||
return (this.operator = this.INVERSIONS[this.operator]);
|
||||
var _ref2;
|
||||
if (('===' === (_ref2 = this.operator) || '!==' === _ref2)) {
|
||||
this.operator = this.INVERSIONS[this.operator];
|
||||
return this;
|
||||
} else return this.second ? new Parens(this).invert() : Op.__super__.invert.call(this);
|
||||
};
|
||||
Op.prototype.toString = function(idt) {
|
||||
return Op.__super__.toString.call(this, idt, this.constructor.name + ' ' + this.operator);
|
||||
@@ -1780,22 +1777,10 @@
|
||||
exports.If = (function() {
|
||||
If = (function() {
|
||||
return function If(condition, _arg, _arg2) {
|
||||
var op;
|
||||
this.tags = _arg2;
|
||||
this.body = _arg;
|
||||
this.tags || (this.tags = {});
|
||||
if (this.tags.invert) {
|
||||
op = condition instanceof Op;
|
||||
if (op && condition.isInvertible()) {
|
||||
condition.invert();
|
||||
} else {
|
||||
if (op && !condition.isUnary()) {
|
||||
condition = new Parens(condition);
|
||||
}
|
||||
condition = new Op('!', condition);
|
||||
}
|
||||
}
|
||||
this.condition = condition;
|
||||
this.condition = this.tags.invert ? condition.invert() : condition;
|
||||
this.elseBody = null;
|
||||
this.isChain = false;
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user