[Pkg-javascript-commits] [backbone] 63/74: passing silent: true now suppresses validations. Issue #52

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:59:09 UTC 2014


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

js pushed a commit to tag 0.3.0
in repository backbone.

commit be37cf01782ff5cae75f4579851a3a501943175e
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Mon Nov 8 15:21:54 2010 -0500

    passing silent: true now suppresses validations. Issue #52
---
 backbone.js   | 6 +++---
 test/model.js | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/backbone.js b/backbone.js
index d12f9d1..b6a610e 100644
--- a/backbone.js
+++ b/backbone.js
@@ -148,7 +148,7 @@
       var now = this.attributes;
 
       // Run validation.
-      if (this.validate && !this._performValidation(attrs, options)) return false;
+      if (!options.silent && this.validate && !this._performValidation(attrs, options)) return false;
 
       // Check for changes of `id`.
       if ('id' in attrs) this.id = attrs.id;
@@ -179,7 +179,7 @@
       // Run validation.
       var validObj = {};
       validObj[attr] = void 0;
-      if (this.validate && !this._performValidation(validObj, options)) return false;
+      if (!options.silent && this.validate && !this._performValidation(validObj, options)) return false;
 
       // Remove the attribute.
       delete this.attributes[attr];
@@ -200,7 +200,7 @@
       // Run validation.
       var validObj = {};
       for (attr in old) validObj[attr] = void 0;
-      if (this.validate && !this._performValidation(validObj, options)) return false;
+      if (!options.silent && this.validate && !this._performValidation(validObj, options)) return false;
 
       this.attributes = {};
       if (!options.silent) {
diff --git a/test/model.js b/test/model.js
index 93ebd07..b55ae44 100644
--- a/test/model.js
+++ b/test/model.js
@@ -169,6 +169,9 @@ $(document).ready(function() {
     equals(result, model);
     equals(model.get('a'), 100);
     equals(lastError, undefined);
+    result = model.set({admin: true}, {silent: true});
+    equals(lastError, undefined);
+    equals(model.get('admin'), true);
     result = model.set({a: 200, admin: true});
     equals(result, false);
     equals(model.get('a'), 100);

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