[Pkg-javascript-commits] [backbone] 68/211: Merging in #167, unsetting 'id'

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:00:03 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 ec6842009cd5e941ba2d4b78b6bb8438c6ca241e
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Mon Feb 7 10:34:42 2011 -0500

    Merging in #167, unsetting 'id'
---
 backbone.js   | 4 +---
 test/model.js | 9 ++++++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/backbone.js b/backbone.js
index 62e6676..2a0deb9 100644
--- a/backbone.js
+++ b/backbone.js
@@ -215,9 +215,7 @@
       // Remove the attribute.
       delete this.attributes[attr];
       delete this._escapedAttributes[attr];
-      if (attr == 'id') {
-          delete this.id;
-      }
+      if (attr == 'id') delete this.id;
       this._changed = true;
       if (!options.silent) {
         this.trigger('change:' + attr, this, void 0, options);
diff --git a/test/model.js b/test/model.js
index 2070bb2..ab62cd5 100644
--- a/test/model.js
+++ b/test/model.js
@@ -133,7 +133,7 @@ $(document).ready(function() {
   });
 
   test("Model: set and unset", function() {
-    attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
+    attrs = {id: 'id', foo: 1, bar: 2, baz: 3};
     a = new Backbone.Model(attrs);
     var changeCount = 0;
     a.bind("change:foo", function() { changeCount += 1; });
@@ -147,6 +147,9 @@ $(document).ready(function() {
     a.unset('foo');
     ok(a.get('foo')== null, "Foo should have changed");
     ok(changeCount == 2, "Change count should have incremented for unset.");
+
+    a.unset('id');
+    equals(a.id, undefined, "Unsetting the id should remove the id property.");
   });
 
   test("Model: set an empty string", function() {
@@ -322,7 +325,7 @@ $(document).ready(function() {
     equals(lastError, "Can't change admin status.");
     equals(boundError, undefined);
   });
-  
+
   test("Model: Inherit class properties", function() {
     var Parent = Backbone.Model.extend({
       instancePropSame: function() {},
@@ -333,7 +336,7 @@ $(document).ready(function() {
     var Child = Parent.extend({
       instancePropDiff: function() {}
     });
-    
+
     var adult = new Parent;
     var kid   = new Child;
 

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