blittle / backbone-nested-models

Backbone Nested Models
86 stars 28 forks source link

Fix bug when `defaults` has a collection. #27

Closed mittsh closed 9 years ago

mittsh commented 9 years ago

When defaults set the value as an empty collection, it was using the collection as the only item of a new collection, e.g.:

        Book = Backbone.Model.extend({
            relations: {
              author: Author,
              pages: Backbone.Collection
            },
            defaults: {
              author: new Author(),
              pages: new Backbone.Collection()
            }
        });

What we expect is that the empty collection is kept.

Adding unit tests for that in defaults.js, passing now, breaking before this change.

blittle commented 9 years ago

Thx for the pull req, released in v2.0.2

mittsh commented 9 years ago

@blittle :+1: awesome!