I know you've only started work on the Backbone-0.9.9 branch but I think the same problem applies. When you initialize a model with a nested attribute and attempt to pass in an object, NestedModel fails on this line:
186: this.changed[attrStr] = newVal;
because this.changed is not initialized yet at that point. I've hacked the problem by adding if(!this.changed) this.changed = {};
right before line 186 but i'm not sure this is a good solution.
Full example:
var model = Backbone.NestedModel.extend({
defaults: {
attr: {}
}
});
Init like this:
var m = new model({ attr: { nestedAttr: "blah" } });
This example fails with:
TypeError: Cannot set property 'attr.nestedAttr' of null
I know you've only started work on the Backbone-0.9.9 branch but I think the same problem applies. When you initialize a model with a nested attribute and attempt to pass in an object, NestedModel fails on this line: 186: this.changed[attrStr] = newVal; because this.changed is not initialized yet at that point. I've hacked the problem by adding if(!this.changed) this.changed = {}; right before line 186 but i'm not sure this is a good solution.
Full example: var model = Backbone.NestedModel.extend({ defaults: { attr: {} } }); Init like this: var m = new model({ attr: { nestedAttr: "blah" } });
This example fails with: TypeError: Cannot set property 'attr.nestedAttr' of null