fix ListView::onMove code
This commit is contained in:
parent
c8d5b4483a
commit
d567e2ac5a
1 changed files with 3 additions and 3 deletions
|
@ -9,11 +9,11 @@ class UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertAt(parentNode, idx, childNode) {
|
function insertAt(parentNode, idx, childNode) {
|
||||||
const isLast = idx === parentNode.childElementCount - 1;
|
const isLast = idx === parentNode.childElementCount;
|
||||||
if (isLast) {
|
if (isLast) {
|
||||||
parentNode.appendChild(childNode);
|
parentNode.appendChild(childNode);
|
||||||
} else {
|
} else {
|
||||||
const nextDomNode = parentNode.children[idx + 1];
|
const nextDomNode = parentNode.children[idx];
|
||||||
parentNode.insertBefore(childNode, nextDomNode);
|
parentNode.insertBefore(childNode, nextDomNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ export default class ListView {
|
||||||
mount() {
|
mount() {
|
||||||
this._subscription = this._collection.subscribe(this);
|
this._subscription = this._collection.subscribe(this);
|
||||||
this._root = html.ul({className: "ListView"});
|
this._root = html.ul({className: "ListView"});
|
||||||
this._childInstances = new Array(this._collection.length);
|
this._childInstances = [];
|
||||||
for (let item of this._collection) {
|
for (let item of this._collection) {
|
||||||
const child = this._childCreator(item);
|
const child = this._childCreator(item);
|
||||||
this._childInstances.push(child);
|
this._childInstances.push(child);
|
||||||
|
|
Reference in a new issue