[Pkg-javascript-commits] [backbone] 196/211: Model is no longer considered to be new if its id is a falsey value
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 17:00:24 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.5.0
in repository backbone.
commit 4e9037b018b888d1814558b3903615b64cebe4af
Author: Gavin Huang <gravof at gmail.com>
Date: Thu Jun 23 16:09:41 2011 +0800
Model is no longer considered to be new if its id is a falsey value
---
backbone.js | 2 +-
test/model.js | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/backbone.js b/backbone.js
index 6005ce0..97c7ebb 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 has a negative
// ID.
isNew : function() {
- return !this.id;
+ 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 e593963..c31d516 100644
--- a/test/model.js
+++ b/test/model.js
@@ -98,6 +98,9 @@ $(document).ready(function() {
attrs = { 'foo': 1, 'bar': 2, 'baz': 3, 'id': -5 };
a = new Backbone.Model(attrs);
ok(!a.isNew(), "any defined ID is legal, negative or positive");
+ attrs = { 'foo': 1, 'bar': 2, 'baz': 3, 'id': 0 };
+ a = new Backbone.Model(attrs);
+ ok(!a.isNew(), "any defined ID is legal, including zero");
});
test("Model: get", 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