afeld / backbone-nested

A plugin to make Backbone.js keep track of nested attributes - looking for maintainers! https://github.com/afeld/backbone-nested/issues/157
https://afeld.github.com/backbone-nested/
MIT License
444 stars 83 forks source link

Look ahead one step when building nested structures (#78) #113

Closed karlwestin closed 10 years ago

karlwestin commented 10 years ago

To determine whether a newly created nest-level should be an object or an array, we need to look at the next value in the path. Please run the tests without the patch in backbone-nested to see the bug in action. Thanks

Closes #78

gkatsev commented 10 years ago

We need to check the next item because otherwise, it'll assume that we're creating a regular object rather than an array, right? Looks good (other than a bit extra whitespace).

karlwestin commented 10 years ago

yeah thats how the bug came out so this bug only really came into effect when you started with setting a big key where nothing of the structure existed before

if you did

new Backbone.NestedModel({
   array: [{ myObject: 10 }]
})

things came out ok, but if you did

new Backbone.NestedModel({
   "array[0].myObject": 10
})

you'd see the bug

Fixed the whitespace, thanks for seeing it

afeld commented 10 years ago

:+1: