fixing If/else-to-ternary with instanceof as an unparenthesized condition. JS operator precedence.

This commit is contained in:
Jeremy Ashkenas
2010-07-23 20:44:56 -07:00
parent 24a5adc898
commit de9fb7777b
5 changed files with 21 additions and 9 deletions

View File

@@ -1330,9 +1330,12 @@ exports.IfNode: class IfNode extends BaseNode
constructor: (condition, body, tags) ->
@condition: condition
@body: body
@elseBody: null
@tags: tags or {}
@condition: new OpNode('!', new ParentheticalNode(@condition)) if @tags.invert
if @tags.invert
@condition: new OpNode('!', new ParentheticalNode(@condition))
else if @condition instanceof OpNode and @condition.operator is 'instanceof'
@condition: new ParentheticalNode(@condition)
@elseBody: null
@isChain: false
bodyNode: -> @body?.unwrap()