[Pkg-javascript-commits] [backbone] 35/281: Reducing the amount of properties we are iterating over by removing the old properties that already exist in now. To do that, previousAttributes had to be cloned. Changing "void 0" return to "undefined".

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:01:54 UTC 2014


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

js pushed a commit to tag 0.9.0
in repository backbone.

commit f6a73ff21df70ed7c9fa9eb821749008e8de9677
Author: Irene Ros <irene at bocoup.com>
Date:   Sat Oct 29 11:51:41 2011 -0400

    Reducing the amount of properties we are iterating over by removing the old properties that already exist in now. To do that, previousAttributes had to be cloned. Changing "void 0" return to "undefined".
---
 backbone.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/backbone.js b/backbone.js
index 20d1e63..361080d 100644
--- a/backbone.js
+++ b/backbone.js
@@ -363,23 +363,26 @@
     // Return an object containing all the attributes that have changed, or false
     // if there are no changed attributes. Useful for determining what parts of a
     // view need to be updated and/or what attributes need to be persisted to
-    // the server.
+    // the server. Unset attributes will be set to undefined.
     changedAttributes : function(now) {
       now || (now = this.attributes);
-      var old = this._previousAttributes;
+      var old = _.clone(this._previousAttributes);
       var changed = false;
       for (var attr in now) {
         if (!_.isEqual(old[attr], now[attr])) {
           changed = changed || {};
           changed[attr] = now[attr];
         }
+        delete old[attr];
       }
-      for (attr in old){
-        if (!(attr in now)){
+      
+      for (var attr in old) {
+        if (typeof now[attr] === 'undefined') {
           changed = changed || {};
-          changed[attr] = void 0;
+          changed[attr] = undefined;
         }
       }
+
       return changed;
     },
 

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