From 992324b425491cb844707cdc3a9fcfdc5e8c66f9 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Thu, 2 Dec 2010 12:55:53 -0500 Subject: [PATCH] fix for #891: incorrect inversion of chained comparisons --- lib/nodes.js | 3 +++ src/nodes.coffee | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nodes.js b/lib/nodes.js index e5c7c241..b5c2868f 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1479,6 +1479,9 @@ var fst, op, _ref; if (op = INVERSIONS[this.operator]) { this.operator = op; + if (this.first.isChainable()) { + this.first.invert(); + } return this; } else if (this.second) { return new Parens(this).invert(); diff --git a/src/nodes.coffee b/src/nodes.coffee index 7eb493e4..d80cbfe6 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1179,6 +1179,7 @@ exports.Op = class Op extends Base invert: -> if op = INVERSIONS[@operator] @operator = op + @first.invert() if @first.isChainable() this else if @second new Parens(this).invert() @@ -1207,7 +1208,7 @@ exports.Op = class Op extends Base # true compileChain: (o) -> [@first.second, shared] = @first.second.cache o - fst = @first .compile o, LEVEL_OP + fst = @first.compile o, LEVEL_OP fst = fst.slice 1, -1 if fst.charAt(0) is '(' code = "#{fst} && #{ shared.compile o } #{@operator} #{ @second.compile o, LEVEL_OP }" if o.level < LEVEL_OP then code else "(#{code})"