documentcloud/backbone — comment on commit 6687cde1969742948523b8f32d67c066b7826d9d
File: backbone.js line 186
By dkonecny:

This change can corrupt model. I discovered this accidentally as I was using latest sources instead of 0.5.3 version. To prevent the corruption this line should be something like:

if (_.isObject(key) || key == null) {

Otherwise when I call model.save(values, {success : function(){} }) and my RESTful PUT web service does not return any data then success handler in save method does "model.set(model.parse(resp, xhr), options)" which in empty response case is "model.set(null, options)" which results into { null : {success : function(){} }} being added into model. I noticed this when I saved my model twice in row - second save fails with error that RESTful WS does not know how to handle "null" attribute.

Hope it help,
-David