[Pkg-javascript-commits] [backbone] 40/173: Always return removed array from #_removeModels

Jonas Smedegaard dr at jones.dk
Wed Aug 31 07:43:59 UTC 2016


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

js pushed a commit to branch master
in repository backbone.

commit 7bbbcc8c51866d26c8b79b70d56a5638e483592d
Author: Justin Ridgewell <justin at ridgewell.name>
Date:   Mon Oct 26 11:19:26 2015 -0400

    Always return removed array from #_removeModels
    
    Fixes #3835.
---
 backbone.js        | 4 ++--
 test/collection.js | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/backbone.js b/backbone.js
index 1b20a08..e0596ca 100644
--- a/backbone.js
+++ b/backbone.js
@@ -809,7 +809,7 @@
       var singular = !_.isArray(models);
       models = singular ? [models] : _.clone(models);
       var removed = this._removeModels(models, options);
-      if (!options.silent && removed) this.trigger('update', this, options);
+      if (!options.silent && removed.length) this.trigger('update', this, options);
       return singular ? removed[0] : removed;
     },
 
@@ -1117,7 +1117,7 @@
         removed.push(model);
         this._removeReference(model, options);
       }
-      return removed.length ? removed : false;
+      return removed;
     },
 
     // Method for checking whether an object should be considered a model for
diff --git a/test/collection.js b/test/collection.js
index 09f8c80..10c6181 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -325,7 +325,7 @@
   });
 
   QUnit.test("remove", function(assert) {
-    assert.expect(11);
+    assert.expect(12);
     var removed = null;
     var result = null;
     col.on('remove', function(model, col, options) {
@@ -348,6 +348,8 @@
     result = col.remove([c, b]);
     assert.equal(result.length, 1, 'only returns removed models');
     assert.equal(result[0], b, 'only returns removed models');
+    result = col.remove([]);
+    assert.deepEqual(result, [], 'returns empty array when nothing removed');
   });
 
   QUnit.test("add and remove return values", function(assert) {

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