Skip to content

Commit cd5252b

Browse files
committed
fixed a bug with wrapped expressions in ?:
1 parent bad69d0 commit cd5252b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/BasicEvaluatedExpression.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ BasicEvaluatedExpression.prototype.asBool = function() {
4545
else if(this.isRegExp()) return true;
4646
else if(this.isArray()) return true;
4747
else if(this.isConstArray()) return true;
48-
else if(this.isWrapped()) return this.prefix || this.postfix ? true : undefined;
48+
else if(this.isWrapped()) return this.prefix && this.prefix.asBool() || this.postfix && this.postfix.asBool() ? true : undefined;
4949
return undefined;
5050
};
5151
BasicEvaluatedExpression.prototype.set = function(value) {

test/cases/parsing/evaluate/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ it("should evaluate null", function() {
1111
require("fail");
1212
});
1313

14+
if("shouldn't evaluate expression", function() {
15+
var value = "";
16+
var x = (value + "") ? "fail" : "ok";
17+
x.should.be.eql("ok");
18+
});
19+
1420
it("should short-circut evaluating", function() {
1521
var expr;
1622
var a = DEBUG && expr ? require("fail") : require("./a");

0 commit comments

Comments
 (0)