expand inherits helper child constructor creation, for clarity.

This commit is contained in:
Jeremy Ashkenas
2010-10-14 13:31:19 -04:00
parent 7c901e2245
commit 9c535ca5a5

View File

@@ -31,8 +31,12 @@
// Similar to `goog.inherits`, but uses a hash of prototype properties and
// class properties to be extended.
var inherits = function(parent, protoProps, classProps) {
var child = protoProps.hasOwnProperty('constructor') ? protoProps.constructor :
function(){ return parent.apply(this, arguments); };
var child;
if (protoProps.hasOwnProperty('constructor')) {
child = protoProps.constructor;
} else {
child = function(){ return parent.apply(this, arguments); };
}
var ctor = function(){};
ctor.prototype = parent.prototype;
child.prototype = new ctor();