Skip to content

Commit 63e4757

Browse files
committed
key nested children by default (fix vuejs#3611)
1 parent d2337df commit 63e4757

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/core/vdom/helpers.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import VNode from './vnode'
55

66
export function normalizeChildren (
77
children: any,
8-
ns: string | void
8+
ns: string | void,
9+
nestedIndex: number | void
910
): Array<VNode> | void {
1011
if (isPrimitive(children)) {
1112
return [createTextVNode(children)]
@@ -17,7 +18,7 @@ export function normalizeChildren (
1718
const last = res[res.length - 1]
1819
// nested
1920
if (Array.isArray(c)) {
20-
res.push.apply(res, normalizeChildren(c, ns))
21+
res.push.apply(res, normalizeChildren(c, ns, i))
2122
} else if (isPrimitive(c)) {
2223
if (last && last.text) {
2324
last.text += String(c)
@@ -33,6 +34,10 @@ export function normalizeChildren (
3334
if (ns) {
3435
applyNS(c, ns)
3536
}
37+
// default key for nested array children (likely generated by v-for)
38+
if (c.key == null && nestedIndex != null) {
39+
c.key = `__vlist_${nestedIndex}_${i}__`
40+
}
3641
res.push(c)
3742
}
3843
}

src/platforms/web/runtime/components/transition-group.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
for (let i = 0; i < rawChildren.length; i++) {
4343
const c = rawChildren[i]
4444
if (c.tag) {
45-
if (c.key != null) {
45+
if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
4646
children.push(c)
4747
map[c.key] = c
4848
;(c.data || (c.data = {})).transition = transitionData

0 commit comments

Comments
 (0)