chore(refactor): make patching child vnode more readable (#992)

Co-authored-by: wangzhangsheng(cary) <wb-wzs728893@alibaba-inc.com>
pull/994/head
cary 3 years ago committed by Jan van Brügge
parent 9e2cecd249
commit 044dfef8c3
No known key found for this signature in database
GPG Key ID: 88E0BF7B7A546481

@ -355,20 +355,20 @@ export function init(
newStartVnode = newCh[++newStartIdx];
}
}
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
if (oldStartIdx > oldEndIdx) {
before = newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].elm;
addVnodes(
parentElm,
before,
newCh,
newStartIdx,
newEndIdx,
insertedVnodeQueue
);
} else {
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
}
if (newStartIdx <= newEndIdx) {
before = newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].elm;
addVnodes(
parentElm,
before,
newCh,
newStartIdx,
newEndIdx,
insertedVnodeQueue
);
}
if (oldStartIdx <= oldEndIdx) {
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
}
}

Loading…
Cancel
Save