mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Fix regression with executable class bodies and prototypal attachment.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user