Skip to content

Commit

Permalink
expand inherits helper child constructor creation, for clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Oct 14, 2010
1 parent 7c901e2 commit 9c535ca
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backbone.js
Expand Up @@ -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();
Expand Down

0 comments on commit 9c535ca

Please sign in to comment.