From 522e090831984804c322abccaf7baaf63ef0a1fd Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Mon, 6 Feb 2012 16:45:06 -0500 Subject: [PATCH 1/2] fixes #964 - collection.get has consistent return --- backbone.js | 2 +- test/collection.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backbone.js b/backbone.js index b5f1fea5..c42cec6d 100644 --- a/backbone.js +++ b/backbone.js @@ -566,7 +566,7 @@ // Get a model from the set by id. get: function(id) { - if (id == null) return null; + if (id == null) return void 0; return this._byId[id.id != null ? id.id : id]; }, diff --git a/test/collection.js b/test/collection.js index f7d3dd51..9f09694a 100644 --- a/test/collection.js +++ b/test/collection.js @@ -516,4 +516,10 @@ $(document).ready(function() { raises(function() { col.add([{id: 1}, {id: 1}]); }); }); + test("#964 - collection.get return in consistent", function() { + var c = new Backbone.Collection(); + ok(c.get(null) === undefined); + ok(c.get() === undefined); + }); + }); From b993441e5e521a03b7cfa86d9a4c741e3c1dd708 Mon Sep 17 00:00:00 2001 From: Stan Angeloff Date: Tue, 7 Feb 2012 14:09:48 +0200 Subject: [PATCH 2/2] Tiny spelling error, no functional changes. --- backbone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backbone.js b/backbone.js index c42cec6d..8595f9c1 100644 --- a/backbone.js +++ b/backbone.js @@ -951,7 +951,7 @@ // // The options object can contain `trigger: true` if you wish to have the // route callback be fired (not usually desirable), or `replace: true`, if - // you which to modify the current URL without adding an entry to the history. + // you wish to modify the current URL without adding an entry to the history. navigate: function(fragment, options) { if (!historyStarted) return false; if (!options || options === true) options = {trigger: options};