diff --git a/main.js b/main.js index 79d801b..a185b22 100644 --- a/main.js +++ b/main.js @@ -63,6 +63,7 @@ function makeClass(base, newProps) { // extend between all classes. constructor.prototype = ownProto; constructor.extend = extend; + constructor.base = baseProto; // Setting constructor.prototype.constructor = constructor is // important so that instanceof works properly in all browsers. diff --git a/test/run.js b/test/run.js index 74dbbe3..081d2f6 100644 --- a/test/run.js +++ b/test/run.js @@ -188,3 +188,32 @@ exports.testStatics = function(t, assert) { t.finish(); }; + +exports.testBaseProperty = function(t, assert) { + var A = Class.extend({ + foo: function() { + return "name: " + this.name; + } + }); + + var B = A.extend({ + name: "B", + + bar: function() { + assert.strictEqual(B.base.bar, this._super); + return B.base.foo.call(this); + } + }); + + var C = B.extend({ + name: "C" + }); + + assert.strictEqual(B.base, A.prototype); + assert.strictEqual(C.base, B.prototype); + + assert.strictEqual(new B().bar(), "name: B"); + assert.strictEqual(new C().bar(), "name: C"); + + t.finish(); +};