From 9599d2d0e97968b25585184f224cdb00f925785c Mon Sep 17 00:00:00 2001 From: Johan Dahlberg Date: Sat, 5 Dec 2009 13:33:15 +0100 Subject: [PATCH] Added superCtor to ctor.super_ instead superCtor.prototype. This way let's us do deep comparison between object instances. I have a suggestion for the sys.inherits function. Today it's impossible to deep comparison between instance and class. Take this snippet for example: function ClassA() {} function ClassB() {} sys.inherits(ClassB, ClassA); var instance = new ClassB(); The instance variable inherits from ClassA but we can't check it (which is useful sometimes). You can compare the instance against ClassB (instance.constructor == ClassB) but we can't compare it deeper (instance.constructor.super == ClassA). The committed change simply assign super to the super constructor instead of the super prototype. I can't see any problem with this fix. You can still get the super constructor by calling super_.prototype. --- src/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index b0a524c..34fd0d6 100644 --- a/src/node.js +++ b/src/node.js @@ -183,7 +183,7 @@ process.EventEmitter.prototype.listeners = function (type) { process.inherits = function (ctor, superCtor) { var tempCtor = function(){}; tempCtor.prototype = superCtor.prototype; - ctor.super_ = superCtor.prototype; + ctor.super_ = superCtor; ctor.prototype = new tempCtor(); ctor.prototype.constructor = ctor; }; -- 2.7.4