diff --git a/backbone.js b/backbone.js index 61127598..2115d2a8 100644 --- a/backbone.js +++ b/backbone.js @@ -162,7 +162,6 @@ // Update attributes. for (var attr in attrs) { var val = attrs[attr]; - if (val === '') val = null; if (!_.isEqual(now[attr], val)) { now[attr] = val; if (!options.silent) { diff --git a/test/model.js b/test/model.js index dff01967..9160f079 100644 --- a/test/model.js +++ b/test/model.js @@ -96,6 +96,12 @@ $(document).ready(function() { ok(changeCount == 2, "Change count should have incremented for unset."); }); + test("Model: set an empty string", function() { + var model = new Backbone.Model({name : "Model"}); + model.set({name : ''}); + equals(model.get('name'), ''); + }); + test("Model: changed, hasChanged, changedAttributes, previous, previousAttributes", function() { var model = new Backbone.Model({name : "Tim", age : 10}); model.bind('change', function() {