From d567e2ac5ad410ebb8a095f996c5c112feac1d34 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 26 Feb 2019 23:27:34 +0100 Subject: [PATCH] fix ListView::onMove code --- src/ui/web/ListView.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/web/ListView.js b/src/ui/web/ListView.js index 2aea9152..ff1ba389 100644 --- a/src/ui/web/ListView.js +++ b/src/ui/web/ListView.js @@ -9,11 +9,11 @@ class UIView { } function insertAt(parentNode, idx, childNode) { - const isLast = idx === parentNode.childElementCount - 1; + const isLast = idx === parentNode.childElementCount; if (isLast) { parentNode.appendChild(childNode); } else { - const nextDomNode = parentNode.children[idx + 1]; + const nextDomNode = parentNode.children[idx]; parentNode.insertBefore(childNode, nextDomNode); } } @@ -36,7 +36,7 @@ export default class ListView { mount() { this._subscription = this._collection.subscribe(this); this._root = html.ul({className: "ListView"}); - this._childInstances = new Array(this._collection.length); + this._childInstances = []; for (let item of this._collection) { const child = this._childCreator(item); this._childInstances.push(child);