Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/virtual-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class VirtualRepeat extends AbstractRepeater {
if (!this._calledGetMore) {
let executeGetMore = () => {
this._calledGetMore = true;
let func = (this.view(0) && this.view(0).firstChild.au) ? this.view(0).firstChild.au['infinite-scroll-next'].instruction.attributes['infinite-scroll-next'] : undefined;
let func = (this.view(0) && this.view(0).firstChild && this.view(0).firstChild.au && this.view(0).firstChild.au['infinite-scroll-next']) ? this.view(0).firstChild.au['infinite-scroll-next'].instruction.attributes['infinite-scroll-next'] : undefined;
let topIndex = this._first;
let isAtBottom = this._bottomBufferHeight === 0;
let isAtTop = this._isAtTop;
Expand Down
28 changes: 28 additions & 0 deletions test/virtual-repeat-integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ describe('VirtualRepeat Integration', () => {
let hiddenVirtualRepeat;
let hiddenViewModel;

let containerComponent;
let containerCreate;
let containerVirtualRepeat;
let containerViewModel;

beforeEach(() => {
items = [];
for(let i = 0; i < 1000; ++i) {
Expand All @@ -214,11 +219,25 @@ describe('VirtualRepeat Integration', () => {
hiddenVirtualRepeat = hiddenComponent.sut;
hiddenViewModel = hiddenComponent.viewModel;
});

containerComponent = StageComponent
.withResources('src/virtual-repeat')
.inView(`<div id="scrollContainer2" style="height: 500px; overflow-y: scroll;">
<div style="height: ${itemHeight}px;" virtual-repeat.for="item of items">\${item}</div>
</div>`)
.boundTo({ items: items });

containerCreate = containerComponent.create().then(() => {
containerVirtualRepeat = containerComponent.sut;
containerViewModel = containerComponent.viewModel;
spyOn(containerVirtualRepeat, '_onScroll').and.callThrough();
});
});

afterEach(() => {
component.cleanUp();
hiddenComponent.cleanUp();
containerComponent.cleanUp();
});

describe('handles delete', () => {
Expand Down Expand Up @@ -326,6 +345,15 @@ describe('VirtualRepeat Integration', () => {
});
});
});

it('handles scrolling to bottom', done => {
containerCreate.then(() => {
validateScroll(containerVirtualRepeat, containerViewModel, () => {
expect(containerVirtualRepeat._onScroll).toHaveBeenCalled();
done();
}, 'scrollContainer2')
});
});
});

describe('iterating table', () => {
Expand Down