mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-23 13:58:06 -05:00
Issue #44 -- Model#set, empty string vs null.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user