Skip to content

Commit

Permalink
fix(runtime-core): avoid transition child key of number type duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwu9145 committed Apr 22, 2022
1 parent 4a3237a commit cc93966
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/runtime-core/src/components/BaseTransition.ts
Expand Up @@ -481,10 +481,17 @@ export function getTransitionRawChildren(
for (let i = 0; i < children.length; i++) {
let child = children[i]
// #5360 inherit parent key in case of <template v-for>
// #5761: when child.key is a number, it would be potentially
// duplicated with index i. In this case, ignore whatever existing
// number type child key (e.g. v-if node could have dedicated key based on branchs).
// Make it completely based on index i in children list to avoid duplication
const key =
parentKey == null
? child.key
: String(parentKey) + String(child.key != null ? child.key : i)
: String(parentKey) +
String(
child.key != null && typeof child.key !== 'number' ? child.key : i
)
// handle fragment children case, e.g. v-for
if (child.type === Fragment) {
if (child.patchFlag & PatchFlags.KEYED_FRAGMENT) keyedFragmentCount++
Expand Down

0 comments on commit cc93966

Please sign in to comment.