mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-19 03:44:23 -05:00
removing the ability to force an if/else chain to be compiled as a statement. Ternaries will now be used as much as possible.
This commit is contained in:
@@ -1488,10 +1488,6 @@ exports.IfNode = class IfNode extends BaseNode
|
||||
bodyNode: -> @body?.unwrap()
|
||||
elseBodyNode: -> @elseBody?.unwrap()
|
||||
|
||||
forceStatement: ->
|
||||
@tags.statement = true
|
||||
this
|
||||
|
||||
# Rewrite a chain of **IfNodes** to add a default case as the final *else*.
|
||||
addElse: (elseBody, statement) ->
|
||||
if @isChain
|
||||
@@ -1504,7 +1500,7 @@ exports.IfNode = class IfNode extends BaseNode
|
||||
# The **IfNode** only compiles into a statement if either of its bodies needs
|
||||
# to be a statement. Otherwise a ternary is safe.
|
||||
isStatement: (o) ->
|
||||
@statement or= !!((o and o.top) or @tags.statement or @bodyNode().isStatement(o) or (@elseBody and @elseBodyNode().isStatement(o)))
|
||||
@statement or= !!((o and o.top) or @bodyNode().isStatement(o) or (@elseBody and @elseBodyNode().isStatement(o)))
|
||||
|
||||
compileCondition: (o) ->
|
||||
conditions = flatten [@condition]
|
||||
|
||||
Reference in New Issue
Block a user