Fix regression with executable class bodies and prototypal attachment.

This commit is contained in:
Jeremy Ashkenas
2013-04-06 09:31:24 +08:00
parent 78d10f30a0
commit 0cadcdc097
3 changed files with 18 additions and 5 deletions

View File

@@ -189,10 +189,11 @@
Base.prototype.traverseChildren = function(crossScope, func) {
return this.eachChild(function(child) {
if (func(child) === false) {
return false;
var recur;
recur = func(child);
if (recur !== false) {
return child.traverseChildren(crossScope, func);
}
return child.traverseChildren(crossScope, func);
});
};

View File

@@ -146,8 +146,8 @@ exports.Base = class Base
traverseChildren: (crossScope, func) ->
@eachChild (child) ->
return false if func(child) is false
child.traverseChildren crossScope, func
recur = func(child)
child.traverseChildren(crossScope, func) unless recur is no
invert: ->
new Op '!', this

View File

@@ -337,6 +337,18 @@ test "#2502: parenthesizing inner object values", ->
eq (new A).sections.default, 0
test "conditional prototype property assignment", ->
debug = false
class Person
if debug
age: -> 10
else
age: -> 20
eq (new Person).age(), 20
test "mild metaprogramming", ->
class Base