Skip to content

Commit

Permalink
bug fix for addChildView
Browse files Browse the repository at this point in the history
  • Loading branch information
taburetkin authored and paulfalgout committed May 23, 2019
1 parent 5090557 commit 182f757
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/collection-view.js
Expand Up @@ -662,10 +662,8 @@ const CollectionView = Backbone.View.extend({

if (_.isObject(index)) {
options = index;
}

// If options has defined index we should use it
if (options.index != null) {
index = options.index;
} else if (options.index != null) {
index = options.index;
}

Expand Down
12 changes: 12 additions & 0 deletions test/unit/collection-view/collection-view-children.spec.js
Expand Up @@ -260,6 +260,18 @@ describe('CollectionView Children', function() {

});

describe('when called with options as second argument and without index in it', function() {
beforeEach(function() {
myCollectionView.addChildView(addView, { });
});

it('should add to the children container with undefined index', function() {
expect(myCollectionView.children._add)
.to.have.been.calledOnce.and.calledWith(addView, void 0);
});

});

describe('when called without preventRender after preventReder calls', function() {
const addIndex = 1;
beforeEach(function() {
Expand Down

0 comments on commit 182f757

Please sign in to comment.