From 463ce3e62d4c80e20cf7ee15734dfa2e2bb1e10b Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Wed, 6 Oct 2010 13:29:36 -0400 Subject: [PATCH] Making zero numeric ids more possible --- backbone.js | 38 +++++++++++++++++++++----------------- test/collection.js | 16 +++++++++++++--- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/backbone.js b/backbone.js index c0fa4774..91caaeb1 100644 --- a/backbone.js +++ b/backbone.js @@ -299,7 +299,7 @@ // Get a model from the set by id. get : function(id) { - return id && this._byId[id.id || id]; + return id && this._byId[id.id != null ? id.id : id]; }, // Get a model from the set by client id. @@ -322,16 +322,17 @@ return this.models[index]; }, - // Add a model, or list of models to the set. Pass silent to avoid firing - // the `added` event for every new model. - add : function(models, silent) { - if (!_.isArray(models)) return this._add(models, silent); - for (var i=0; i