Closed nibrag closed 10 years ago
var Foo = Backbone.AssociatedModel.extend({}); var Bar = Backbone.AssociatedModel.extend({ relations: [ { type: Backbone.One, key: 'rel', relatedModel: Foo, map: function(m) { if(m.rel.test == '') return null; return m; } } ], }); var bar = new Bar({rel: {'test': ''}});
this code raised exeption:
Uncaught TypeError: Cannot call method 'hasOwnProperty' of null backbone-associations.js:314 (anonymous function) backbone-associations.js:314 _.each._.forEach underscore.js:79 Backbone.AssociatedModel.Backbone.Associations.AssociatedModel.BackboneModel.extend._setAttr backbone-associations.js:259 Backbone.AssociatedModel.Backbone.Associations.AssociatedModel.BackboneModel.extend._set backbone-associations.js:233 Backbone.AssociatedModel.Backbone.Associations.AssociatedModel.BackboneModel.extend.set backbone-associations.js:197 Backbone.Model backbone-min.js:266 Backbone.AssociatedModel.Backbone.Associations.AssociatedModel.BackboneModel.extend.constructor backbone-associations.js:115 Backbone.AssociatedModel.extend._.extend.constructor notified-model.js:7 child backbone-min.js:1583 _.extend._prepareModel backbone-min.js:929 _.extend.set backbone-min.js:720 _.each.CollectionProto.(anonymous function) backbone-associations.js:795 _.extend.add backbone-min.js:652 _.extend.reset backbone-min.js:783 _.each.CollectionProto.(anonymous function) backbone-associations.js:795 _.extend.fetch.options.success backbone-min.js:879 x.Callbacks.c jquery-1.10.1.min.js:745 x.Callbacks.p.fireWith jquery-1.10.1.min.js:779 k jquery-1.10.1.min.js:1872 x.ajaxTransport.send.r
This fix does not terminate the recursion. Let me know if you have any issues...
this code raised exeption: