Skip to content

Commit

Permalink
Fix jashkenas#1057 - Save with wait validates model.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Mar 18, 2012
1 parent 01fb414 commit 6948b59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@
}

options = options ? _.clone(options) : {};
if (options.wait) current = _.clone(this.attributes);
if (options.wait) {
if (!this._validate(attrs, options)) return false;
current = _.clone(this.attributes);
}
var silentOptions = _.extend({}, options, {silent: true});
if (attrs && !this.set(attrs, options.wait ? silentOptions : options)) {
return false;
Expand Down
6 changes: 6 additions & 0 deletions test/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,12 @@ $(document).ready(function() {
equal(changed, 1);
});

test("save with wait validates attributes", 1, function() {
var model = new Backbone.Model();
model.validate = function() { ok(true); };
model.save({x: 1}, {wait: true});
});

test("nested `set` during `'change:attr'`", function() {
var events = [];
var model = new Backbone.Model();
Expand Down

0 comments on commit 6948b59

Please sign in to comment.