test: add tests for rendererChildren (#52)

* test: [wip] add tests for rendererChildren

* chore: use serializeInner for clearer output

* fix: should remove the text node if content is empty

* test: also test for appended content

* test: inserting & removing

* test: moving children

* refactor: use a helper function

* test: finish tests

* test: duplicate keys tests belong to keyed children block

* fix(runtime-test): fix insert when moving node in the same parent

* fix: fix failing test cases for rendererChildren

* test: handle rendererChildren edge case
This commit is contained in:
Haoqun Jiang
2019-09-21 06:17:35 +08:00
committed by Evan You
parent c78d47b788
commit b275f8697d
3 changed files with 631 additions and 36 deletions

View File

@@ -1512,7 +1512,10 @@ export function createRenderer<
} else {
// key-less node, try to locate a key-less node of the same type
for (j = s2; j <= e2; j++) {
if (isSameType(prevChild, c2[j] as HostVNode)) {
if (
newIndexToOldIndexMap[j - s2] === 0 &&
isSameType(prevChild, c2[j] as HostVNode)
) {
newIndex = j
break
}