[Pkg-javascript-commits] [backbone] 49/74: Make protoProps optional, when inheriting.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:59:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.3.0
in repository backbone.

commit 9a74dbc9c3ba3cf00157f0469b00fbee953600aa
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Sat Nov 6 09:48:56 2010 -0400

    Make protoProps optional, when inheriting.
---
 backbone.js   | 7 ++++---
 test/model.js | 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/backbone.js b/backbone.js
index 29ae3db..8de433e 100644
--- a/backbone.js
+++ b/backbone.js
@@ -751,7 +751,7 @@
     // The constructor function for the new subclass is either defined by you
     // (the "constructor" property in your `extend` definition), or defaulted
     // by us to simply call `super()`.
-    if (protoProps.hasOwnProperty('constructor')) {
+    if (protoProps && protoProps.hasOwnProperty('constructor')) {
       child = protoProps.constructor;
     } else {
       child = function(){ return parent.apply(this, arguments); };
@@ -762,8 +762,9 @@
     ctor.prototype = parent.prototype;
     child.prototype = new ctor();
 
-    // Add prototype properties (instance properties) to the subclass.
-    _.extend(child.prototype, protoProps);
+    // Add prototype properties (instance properties) to the subclass,
+    // if supplied.
+    if (protoProps) _.extend(child.prototype, protoProps);
 
     // Add static properties to the constructor function, if supplied.
     if (staticProps) _.extend(child, staticProps);
diff --git a/test/model.js b/test/model.js
index 5e46fce..93ebd07 100644
--- a/test/model.js
+++ b/test/model.js
@@ -19,7 +19,8 @@ $(document).ready(function() {
     length : 123
   };
 
-  var doc = new Backbone.Model(attrs);
+  var proxy = Backbone.Model.extend();
+  var doc = new proxy(attrs);
 
   var klass = Backbone.Collection.extend({
     url : function() { return '/collection'; }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list