From 9c535ca5a55fa2003146270e745258415b6083a4 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Thu, 14 Oct 2010 13:31:19 -0400 Subject: [PATCH] expand inherits helper child constructor creation, for clarity. --- backbone.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backbone.js b/backbone.js index 4d1a6c4b..064b497b 100644 --- a/backbone.js +++ b/backbone.js @@ -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();