[Pkg-javascript-commits] [backbone] 27/101: fixing refresh for attributes only

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:58:26 UTC 2014


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

js pushed a commit to tag 0.1.0
in repository backbone.

commit a29dd5c5114b09e6704e1db2536330fb97afacf9
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Mon Oct 4 16:02:39 2010 -0400

    fixing refresh for attributes only
---
 backbone.js | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/backbone.js b/backbone.js
index f1ea2ca..a4484f2 100644
--- a/backbone.js
+++ b/backbone.js
@@ -18,12 +18,11 @@
   (typeof exports !== 'undefined' ? exports : this).Backbone = Backbone;
 
   // Helper function to correctly set up the prototype chain, for subclasses.
+  // Similar to `goog.inherits`, but uses a hash of prototype properties and
+  // static properties to be extended.
   var inherits = function(parent, protoProps, classProps) {
-    if (protoProps.hasOwnProperty('constructor')) {
-      child = protoProps.constructor;
-    } else {
-      child = function(){ return parent.apply(this, arguments); };
-    }
+    var child = protoProps.hasOwnProperty('constructor') ? protoProps.constructor :
+                function(){ return parent.apply(this, arguments); };
     var ctor = function(){};
     ctor.prototype = parent.prototype;
     child.prototype = new ctor();
@@ -379,10 +378,13 @@
     // any `added` or `removed` events. Fires `refreshed` when finished.
     refresh : function(models, silent) {
       models = models || [];
+      var collection = this;
       if (models[0] && !(models[0] instanceof Backbone.Model)) {
-        _.each(models, _.bind(function(model,i) {
+        models = _.map(models, function(attrs, i) {
+          var model = new collection.model(attrs);
           model.collection = this;
-        }, this));
+          return model;
+        });
       }
       this._initialize();
       this.add(models, true);

-- 
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