mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
fix another long ternary in the lib
This commit is contained in:
@@ -1864,7 +1864,12 @@
|
||||
Existence.prototype.compileNode = function(o) {
|
||||
var cmp, cnj, code, _ref2;
|
||||
code = this.expression.compile(o, LEVEL_OP);
|
||||
code = IDENTIFIER.test(code) && !o.scope.check(code) ? ((_ref2 = this.negated ? ['===', '||'] : ['!==', '&&'], cmp = _ref2[0], cnj = _ref2[1], _ref2), "typeof " + code + " " + cmp + " \"undefined\" " + cnj + " " + code + " " + cmp + " null") : "" + code + " " + (this.negated ? '==' : '!=') + " null";
|
||||
if (IDENTIFIER.test(code) && !o.scope.check(code)) {
|
||||
_ref2 = this.negated ? ['===', '||'] : ['!==', '&&'], cmp = _ref2[0], cnj = _ref2[1];
|
||||
code = "typeof " + code + " " + cmp + " \"undefined\" " + cnj + " " + code + " " + cmp + " null";
|
||||
} else {
|
||||
code = "" + code + " " + (this.negated ? '==' : '!=') + " null";
|
||||
}
|
||||
if (o.level <= LEVEL_COND) {
|
||||
return code;
|
||||
} else {
|
||||
|
||||
@@ -1451,12 +1451,12 @@ exports.Existence = class Existence extends Base
|
||||
|
||||
compileNode: (o) ->
|
||||
code = @expression.compile o, LEVEL_OP
|
||||
code = if IDENTIFIER.test(code) and not o.scope.check code
|
||||
[cmp, cnj] = if @negated then ['===', '||'] else ['!==', '&&']
|
||||
"typeof #{code} #{cmp} \"undefined\" #{cnj} #{code} #{cmp} null"
|
||||
if IDENTIFIER.test(code) and not o.scope.check code
|
||||
[cmp, cnj] = if @negated then ['===', '||'] else ['!==', '&&']
|
||||
code = "typeof #{code} #{cmp} \"undefined\" #{cnj} #{code} #{cmp} null"
|
||||
else
|
||||
# do not use strict equality here; it will break existing code
|
||||
"#{code} #{if @negated then '==' else '!='} null"
|
||||
code = "#{code} #{if @negated then '==' else '!='} null"
|
||||
if o.level <= LEVEL_COND then code else "(#{code})"
|
||||
|
||||
#### Parens
|
||||
|
||||
Reference in New Issue
Block a user