[Pkg-javascript-commits] [backbone] 159/281: collection.add should not alter models array
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 17:02:07 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 c8919c4b053a18d6913c8d7066bf110ac552db74
Author: Brad Dunbar <dunbarb2 at gmail.com>
Date: Tue Jan 10 17:18:11 2012 -0500
collection.add should not alter models array
---
backbone.js | 1 +
test/collection.js | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/backbone.js b/backbone.js
index 85a74ce..bc6fa0a 100644
--- a/backbone.js
+++ b/backbone.js
@@ -420,6 +420,7 @@
var i, l;
options || (options = {});
if (!_.isArray(models)) models = [models];
+ models = slice.call(models);
for (i = 0, l = models.length; i < l; i++) {
models[i] = this._add(models[i], options);
}
diff --git a/test/collection.js b/test/collection.js
index 4f5984d..02f4eb2 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -417,4 +417,12 @@ $(document).ready(function() {
equals(fired, true);
});
+ test("Collection: add does not alter arguments", function(){
+ var attrs = {};
+ var models = [attrs];
+ new Backbone.Collection().add(models);
+ equal(models.length, 1);
+ ok(attrs === models[0]);
+ });
+
});
--
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