diff --git a/src/model.js b/src/model.js index b17cefa5..5db70c7a 100644 --- a/src/model.js +++ b/src/model.js @@ -97,6 +97,7 @@ my.Field = Backbone.Model.extend({ // if a hash not passed in the first argument is set as value for key 0 if ('0' in data) { this.set({id: data['0']}); + this.unset('0'); } if (this.attributes.label == null) { this.set({label: this.id}); diff --git a/test/model.test.js b/test/model.test.js index 33941a58..41d50ab4 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -16,6 +16,7 @@ test('Field: basics', function () { var field = new recline.Model.Field('x'); equal(field.id, 'x', 'Set of id from single argumentst to ctor'); equal(field.attributes.id, 'x', 'Set of id from single argumentst to ctor'); + ok(!('0' in field.toJSON()), 'Should have removed artificially created 0 key in attributes'); }); })(this.jQuery);