benjamn / cls

Class factory featuring inheritance of static properties, static constructors, lazy population of prototypes, and this._super

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a .base property to class constructors for easy base class access

benjamn opened this issue · comments

This would enable the following style as an alternative to this._super:

var SubClass = BaseClass.extend({
    init: function(arg) {
        // These should all be equivalent:
        SubClass.base.init.call(this, arg);
        SubClass.base.init.apply(this, arguments);
        this._super(arg);
        this._super.apply(this, arguments);
    }
});

// Just to be perfectly clear:
assert(SubClass.base === BaseClass.prototype);