[Pkg-javascript-commits] [backbone] 18/21: isNew should use id, not idAttribute

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


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

js pushed a commit to tag 0.5.2
in repository backbone.

commit 3145b4db2242aa18ecf582c70c84fdd0c731a3c6
Author: Chris Moore <cdmwebs at gmail.com>
Date:   Mon Jul 25 17:48:09 2011 -0400

    isNew should use id, not idAttribute
---
 backbone.js   | 2 +-
 test/model.js | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/backbone.js b/backbone.js
index c793c65..469c479 100644
--- a/backbone.js
+++ b/backbone.js
@@ -342,7 +342,7 @@
 
     // A model is new if it has never been saved to the server, and lacks an id.
     isNew : function() {
-      return this[this.idAttribute] == null;
+      return this.id == null;
     },
 
     // Call this method to manually fire a `change` event for this model.
diff --git a/test/model.js b/test/model.js
index 3bb8ffe..7ad0d71 100644
--- a/test/model.js
+++ b/test/model.js
@@ -175,8 +175,10 @@ $(document).ready(function() {
     var model = new MongoModel({id: 'eye-dee', _id: 25, title: 'Model'});
     equals(model.get('id'), 'eye-dee');
     equals(model.id, 25);
+    equals(model.isNew(), false);
     model.unset('_id');
     equals(model.id, undefined);
+    equals(model.isNew(), true);
   });
 
   test("Model: set an empty string", function() {

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