Skip to content

Commit

Permalink
fix(collectionRepeat): properly display sibling elements after a coll…
Browse files Browse the repository at this point in the history
…ection-repeat
  • Loading branch information
perrygovier committed Jan 21, 2015
1 parent 0e11a08 commit 7913ee0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 0 additions & 1 deletion js/angular/directive/collectionRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ function($collectionRepeatManager, $collectionDataSource, $parse) {
before = false;
} else {
if (node.hasAttribute('collection-repeat-ignore')) return;
if (node.nodeName === 'ION-INFINITE-SCROLL')return;
var width = node.offsetWidth;
var height = node.offsetHeight;
if (width && height) {
Expand Down
3 changes: 1 addition & 2 deletions js/angular/service/collectionRepeatDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ function($cacheFactory, $parse, $rootScope) {
// Subtract so we start at the beginning of this.data, after
// this.beforeSiblings.
index -= this.dataStartIndex;

if (index > this.data.length - 1) {
return this.afterSiblings[index - this.dataStartIndex];
return this.afterSiblings[index - this.data.length];
}

var item = this.getItem(index);
Expand Down
18 changes: 16 additions & 2 deletions test/unit/angular/service/collectionDataSource.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('$collectionDataSource service', function() {

beforeEach(module('ionic'));

function setup(options, template) {
function setup(options, template, dataSourceOptions) {
var dataSource;
inject(function($rootScope, $compile, $collectionDataSource) {
options = angular.extend({
Expand All @@ -24,6 +24,9 @@ describe('$collectionDataSource service', function() {
dataSource.dataStartIndex = 0;
dataSource.beforeSiblings = [];
dataSource.afterSiblings = [];
if (dataSourceOptions && dataSourceOptions.afterSiblings) {
dataSource.afterSiblings = dataSourceOptions.afterSiblings;
}
});
return dataSource;
}
Expand Down Expand Up @@ -123,7 +126,13 @@ describe('$collectionDataSource service', function() {
it('should return a value with index values set and put in attachedItems', inject(function($rootScope) {
var source = setup({
keyExpr: 'value'
});
}, null, {afterSiblings:[{
width: 50,
height: 50,
element: angular.element('<div class="tail"></div>'),
scope: null,
isOutside: true
}]});
source.data = ['a', 'b', 'c'];
source.dimensions = ['a','b','c'];
spyOn(source, 'getItem').andCallFake(function() {
Expand Down Expand Up @@ -159,6 +168,11 @@ describe('$collectionDataSource service', function() {
1: item2,
2: item3
});

var item4 = source.attachItemAtIndex(3);

expect(item4.width).toEqual(50);
expect(item4.isOutside).toEqual(true);
}));
});

Expand Down

0 comments on commit 7913ee0

Please sign in to comment.