recording else_body as a child of IfNode, when added after the face

This commit is contained in:
Jeremy Ashkenas 2010-02-13 09:44:12 -05:00
parent 13b2dc8d31
commit 785c4fb5a0
2 changed files with 2 additions and 0 deletions

View File

@ -1182,6 +1182,7 @@
// Rewrite a chain of IfNodes to add a default case as the final else.
add_else: function add_else(exprs) {
this.is_chain() ? this.else_body.add_else(exprs) : (this.else_body = exprs && exprs.unwrap());
this.children.push(exprs);
return this;
},
// If the else_body is an IfNode itself, then we've got an if-else chain.

View File

@ -960,6 +960,7 @@ IfNode: exports.IfNode: inherit Node, {
# Rewrite a chain of IfNodes to add a default case as the final else.
add_else: (exprs) ->
if @is_chain() then @else_body.add_else(exprs) else @else_body: exprs and exprs.unwrap()
@children.push(exprs)
this
# If the else_body is an IfNode itself, then we've got an if-else chain.