From 047d0d6bf4c3b50240c19a025c29422cdcaa6dbd Mon Sep 17 00:00:00 2001 From: Tim Griesser Date: Wed, 26 Dec 2012 13:07:36 -0500 Subject: [PATCH] using typeof rather than _.isObject for model.save --- backbone.js | 2 +- test/model.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backbone.js b/backbone.js index 144ced39..28a7dc50 100644 --- a/backbone.js +++ b/backbone.js @@ -461,7 +461,7 @@ model.attributes = attributes; var serverAttrs = model.parse(resp, options); if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); - if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) { + if (typeof serverAttrs === 'object' && !model.set(serverAttrs, options)) { return false; } if (success) success(model, resp, options); diff --git a/test/model.js b/test/model.js index 98970b34..9bbbe4c8 100644 --- a/test/model.js +++ b/test/model.js @@ -423,10 +423,11 @@ $(document).ready(function() { equal(model.get('title'), 'Twelfth Night'); }); - test("save with non-object success response", 1, function () { + test("save with non-object success response", 2, function () { var model = new Backbone.Model(); model.sync = function(method, model, options) { options.success(model, '', options); + options.success(model, null, options); }; model.save({testing:'empty'}, { success: function (model) {