Fix bug with subclass helper

This commit is contained in:
Andrew Stewart 2014-02-25 10:14:30 -08:00
parent 7aa0bf0dfd
commit 79b5e9947e
2 changed files with 11 additions and 9 deletions

6
dist/utils.js vendored
View File

@ -38,14 +38,14 @@
global.subclass = function(child, parent) {
var ctor, key;
ctor = function() {
this.constructor = child;
};
for (key in parent) {
if (hasProp.call(parent, key)) {
child[key] = parent[key];
}
}
ctor = function() {
return this.constructor = child;
};
ctor.prototype = parent.prototype;
child.prototype = new ctor();
child.__super__ = parent.prototype;

View File

@ -72,14 +72,16 @@ global.hasProp = {}.hasOwnProperty
#
# Returns subclass
global.subclass = (child, parent) ->
ctor = ->
@constructor = child
return
for key of parent
child[key] = parent[key] if hasProp.call(parent, key)
child[key] = parent[key] if hasProp.call(parent, key)
ctor = -> @constructor = child
ctor.prototype = parent.prototype
child.prototype = new ctor()
child.__super__ = parent.prototype
ctor:: = parent::
child:: = new ctor()
child.__super__ = parent::
child
# Public: Function for instantiating a class with all passed arguments to