Skip to content
qtoden edited this page Sep 12, 2012 · 2 revisions

This project uses John Resig's Simple JavaScript Inheritance to simulate classical object oriented inheritance. However, to make the code compile in Google Closure's advanced mode, some modifications had to be made to the API.

Resig's original API worked like this:

SubClass = SuperClass.extend({
    init: function () {
        // ...
    },
    // ...
}

That approach still works, but if you want the project to compile with Closure, the API must instead be used like this:

/**
 * @constructor
 * @extends SuperClass
 */
SubClass = Class.extend(SuperClass,
/** @lends {SubClass.prototype} */
{
    /** @constructs */
    init: function () {
        // ...
    },
    // ...
}

This is because Closure can't find the extend function in any "class" derived from Class.

Clone this wiki locally