Fix bug with subclass helper
This commit is contained in:
parent
7aa0bf0dfd
commit
79b5e9947e
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue