From c98d9ce0fc69c27bcdad994b99579a34f7f49fc6 Mon Sep 17 00:00:00 2001 From: James Coglan Date: Wed, 13 Aug 2008 14:54:57 +0100 Subject: [PATCH] For subclasses, the prototype must be assigned before new properties are added to it. --- source/compiler.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/compiler.js b/source/compiler.js index b2b6d520..39b7146f 100644 --- a/source/compiler.js +++ b/source/compiler.js @@ -40,6 +40,7 @@ JS.ClassCompiler = new JS.Class({ declaration: function() { var str = this._className + ' = ' + this._subject.toString() + ';\n'; + if (this._subject.superclass != Object) str += this.subclass(); str += this._className + '.prototype.constructor = \n'; str += this._className + '.prototype.klass = ' + this._className + ';\n'; var superclass = this._subject.superclass; @@ -79,10 +80,7 @@ JS.ClassCompiler = new JS.Class({ }, instanceMethods: function() { - var str = ''; - if (this._subject.superclass != Object) str += this.subclass(); - - var anc = this._subject.ancestors(), methods = {}, method; + var anc = this._subject.ancestors(), methods = {}, str = '', method; for (var i = 0, n = anc.length; i < n; i++) { if (anc[i] == JS.ObjectMethods) continue; JS.extend(methods, anc[i].__mod__.__fns__);