append all list items at once for initial render

This commit is contained in:
Bruno Windels 2020-08-17 17:58:04 +02:00
parent 1c779cf95c
commit df8d884d91

View File

@ -102,12 +102,14 @@ export class ListView {
} }
this._subscription = this._list.subscribe(this); this._subscription = this._list.subscribe(this);
this._childInstances = []; this._childInstances = [];
const fragment = document.createDocumentFragment();
for (let item of this._list) { for (let item of this._list) {
const child = this._childCreator(item); const child = this._childCreator(item);
this._childInstances.push(child); this._childInstances.push(child);
const childDomNode = child.mount(this._mountArgs); const childDomNode = child.mount(this._mountArgs);
this._root.appendChild(childDomNode); fragment.appendChild(childDomNode);
} }
this._root.appendChild(fragment);
} }
onAdd(idx, value) { onAdd(idx, value) {