From 2da6c1a29799da5a014e4411e6479c4de8abefc0 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Sat, 18 Feb 2012 07:48:14 +0000 Subject: [PATCH] [#25,model][xs]: remove artificial field attribute (follow up to penultimate commit cf42e43ff0f32ba24e940455b060ae278025942b). --- src/model.js | 1 + test/model.test.js | 1 + 2 files changed, 2 insertions(+) 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);