Author: jruchaud Date: 2014-09-08 12:04:40 +0200 (Mon, 08 Sep 2014) New Revision: 724 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/724 Log: Simplify Modified: funjs/public_html/funjs/Class.js Modified: funjs/public_html/funjs/Class.js =================================================================== --- funjs/public_html/funjs/Class.js 2014-07-04 15:00:33 UTC (rev 723) +++ funjs/public_html/funjs/Class.js 2014-09-08 10:04:40 UTC (rev 724) @@ -1,25 +1,16 @@ -var Class = function() { - this.init && this.init.apply(this, arguments); -}; +var Class = new Function(); -Class.extend = function(proto) { +Function.prototype.extend = function(proto) { var parent = this; var child = function() { this.init && this.init.apply(this, arguments); }; - child.extend = parent.extend; - var Wrapper = new Function(); - Wrapper.prototype = parent.prototype; + child.prototype = proto; + child.prototype.__proto__ = parent.prototype; + child.prototype.super = parent.prototype; - var wrapper = new Wrapper(); - for (var key in proto) { - wrapper[key] = proto[key]; - } - - child.prototype = wrapper; - child.prototype.super = wrapper.__proto__; return child; }; @@ -58,4 +49,4 @@ a = new A(); b = new B(); c = new C(); -} +} \ No newline at end of file
participants (1)
-
jruchaud@users.nuiton.org