Issue #860. Nested classes.

This commit is contained in:
Jeremy Ashkenas 2010-11-28 14:56:07 -08:00
parent 1254efaddb
commit 4afa6a2887
3 changed files with 17 additions and 0 deletions

View File

@ -977,6 +977,9 @@
Class.prototype.walkBody = function(name) {
return this.traverseChildren(false, __bind(function(child) {
var exps, i, node, _len, _ref;
if (child instanceof Class) {
return false;
}
if (child instanceof Expressions) {
_ref = exps = child.expressions;
for (i = 0, _len = _ref.length; i < _len; i++) {

View File

@ -786,6 +786,7 @@ exports.Class = class Class extends Base
# Walk the body of the class, looking for prototype properties to be converted.
walkBody: (name) ->
@traverseChildren false, (child) =>
return false if child instanceof Class
if child instanceof Expressions
for node, i in exps = child.expressions
if node instanceof Value and node.isObject(true)

View File

@ -318,3 +318,16 @@ class two.Klass
eq typeof Klass, 'undefined'
eq one.Klass.label, 'one'
eq two.Klass.label, 'two'
# Nested classes.
class Outer
constructor: ->
@label = 'outer'
class @Inner
constructor: ->
@label = 'inner'
eq (new Outer).label, 'outer'
eq (new Outer.Inner).label, 'inner'