[Pkg-javascript-commits] [backbone] 82/281: unset accepts var args
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 17:01:59 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.9.0
in repository backbone.
commit d87144d6cb4d26c7321d5ad5ebf8f6d7dc4a4e4b
Author: Brad Dunbar <dunbarb2 at gmail.com>
Date: Fri Nov 11 10:55:36 2011 -0500
unset accepts var args
---
backbone.js | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/backbone.js b/backbone.js
index 3ec4c29..06b444f 100644
--- a/backbone.js
+++ b/backbone.js
@@ -222,8 +222,11 @@
// Remove an attribute from the model, firing `"change"` unless you choose
// to silence it. `unset` is a noop if the attribute doesn't exist.
unset : function(attrs, options) {
- var key = attrs;
- if (_.isString(key)) (attrs = {})[key] = void 0;
+ if (_.isString(attrs)) {
+ var key, args = _.toArray(arguments), attrs = {};
+ while (_.isString(key = args.shift())) attrs[key] = void 0;
+ options = key;
+ }
(options || (options = {})).unset = true;
return this.set(attrs, options);
},
@@ -231,9 +234,8 @@
// Clear all attributes on the model, firing `"change"` unless you choose
// to silence it.
clear : function(options) {
- var attrs = {};
- for (var attr in this.attributes) if (attr != this.idAttribute) attrs[attr] = void 0;
- return this.unset(attrs);
+ var keys = _.without(_.keys(this.attributes), 'id');
+ return this.unset.apply(this, keys.concat([options]));
},
// Fetch the model from the server. If the server's representation of the
--
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