+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.title}}
+
+
+ {{item.date}}
+
+
+
+
+
+
+
+
diff --git a/src/components/virtual-scroll/test/virtual-scroll.spec.ts b/src/components/virtual-scroll/test/virtual-scroll.spec.ts
index eadfb8010d..3ef0c6e0f4 100644
--- a/src/components/virtual-scroll/test/virtual-scroll.spec.ts
+++ b/src/components/virtual-scroll/test/virtual-scroll.spec.ts
@@ -1,5 +1,5 @@
import { VirtualCell, VirtualData, VirtualNode } from '../virtual-util';
-import { processRecords, populateNodeData, initReadNodes, getVirtualHeight, adjustRendered } from '../virtual-util';
+import { processRecords, populateNodeData, initReadNodes, getVirtualHeight, adjustRendered, estimateHeight } from '../virtual-util';
describe('VirtualScroll', () => {
@@ -32,6 +32,15 @@ describe('VirtualScroll', () => {
};
});
+ describe('estimateHeight', () => {
+
+ it('should return zero when no records', () => {
+ const h = estimateHeight(0, undefined, 100, .25);
+ expect(h).toEqual(0);
+ });
+
+ });
+
describe('processRecords', () => {
it('should load data for 100% width items', () => {
@@ -212,6 +221,20 @@ describe('VirtualScroll', () => {
describe('populateNodeData', () => {
+ it('should set no nodes when no records', () => {
+ nodes = [];
+ records = [];
+
+ let startCellIndex = 0;
+ let endCellIndex = 0;
+
+ populateNodeData(startCellIndex, endCellIndex, data.viewWidth, true,
+ cells, records, nodes, viewContainer,
+ itmTmp, hdrTmp, ftrTmp, false);
+
+ expect(nodes.length).toBe(0);
+ });
+
it('should skip already rendered, and create nodes', () => {
cells = [
{row: 0, tmpl: TEMPLATE_ITEM},
diff --git a/src/components/virtual-scroll/virtual-scroll.ts b/src/components/virtual-scroll/virtual-scroll.ts
index 034f228bb7..dbadc82f41 100644
--- a/src/components/virtual-scroll/virtual-scroll.ts
+++ b/src/components/virtual-scroll/virtual-scroll.ts
@@ -363,9 +363,9 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
* DOM READ THEN DOM WRITE
*/
update(checkChanges: boolean) {
- var self = this;
+ const self = this;
- if (!self._records || !self._records.length) return;
+ if (!self._records) return;
if (checkChanges) {
if (isPresent(self._differ)) {
diff --git a/src/components/virtual-scroll/virtual-util.ts b/src/components/virtual-scroll/virtual-util.ts
index aabfee27e2..a4cea507b0 100644
--- a/src/components/virtual-scroll/virtual-util.ts
+++ b/src/components/virtual-scroll/virtual-util.ts
@@ -131,6 +131,13 @@ export function populateNodeData(startCellIndex: number, endCellIndex: number, v
cells: VirtualCell[], records: any[], nodes: VirtualNode[], viewContainer: ViewContainerRef,
itmTmp: TemplateRef