[Pkg-javascript-commits] [backbone] 20/211: Issue #132 ... initial _changed after new with attributes.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:59:58 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 53ae5b5cdfaae0dc8ccfd6cf60d477cfb0561bbc
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Fri Dec 10 11:58:41 2010 -0500

    Issue #132 ... initial _changed after new with attributes.
---
 backbone.js   | 1 +
 test/model.js | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/backbone.js b/backbone.js
index 15d888c..ec1ad2d 100644
--- a/backbone.js
+++ b/backbone.js
@@ -121,6 +121,7 @@
     this._escapedAttributes = {};
     this.cid = _.uniqueId('c');
     this.set(attributes, {silent : true});
+    this._changed = false;
     this._previousAttributes = _.clone(this.attributes);
     if (options && options.collection) this.collection = options.collection;
     this.initialize(attributes, options);
diff --git a/test/model.js b/test/model.js
index b6a189c..b90f77d 100644
--- a/test/model.js
+++ b/test/model.js
@@ -204,6 +204,15 @@ $(document).ready(function() {
     equals(value, 'Ms. Sue');
   });
 
+  test("Model: change after initialize", function () {
+    var changed = 0;
+    var attrs = {id: 1, label: 'c'};
+    var obj = new Backbone.Model(attrs);
+    obj.bind('change', function() { changed += 1; });
+    obj.set(attrs);
+    equals(changed, 0);
+  });
+
   test("Model: save within change event", function () {
     var model = new Backbone.Model({firstName : "Taylor", lastName: "Swift"});
     model.bind('change', 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