Skip to content

Commit 006e82d

Browse files
committed
warning for duplicate objects during v-repeat diff
1 parent f0cf2c6 commit 006e82d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/directives/repeat.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ module.exports = {
265265
primitive = !isObject(raw)
266266
vm = !init && this.getVm(raw, i, converted ? obj.$key : null)
267267
if (vm) { // reusable instance
268+
269+
if (process.env.NODE_ENV !== 'production' && vm._reused) {
270+
_.warn(
271+
'Duplicate objects found in v-repeat="' + this.expression + '": ' +
272+
JSON.stringify(raw)
273+
)
274+
}
275+
268276
vm._reused = true
269277
vm.$index = i // update $index
270278
// update data for track-by or object repeat,
@@ -462,7 +470,7 @@ module.exports = {
462470
cache[id] = vm
463471
} else if (!primitive && idKey !== '$index') {
464472
process.env.NODE_ENV !== 'production' && _.warn(
465-
'Duplicate track-by key in v-repeat: ' + id
473+
'Duplicate objects with the same track-by key in v-repeat: ' + id
466474
)
467475
}
468476
} else {
@@ -472,8 +480,8 @@ module.exports = {
472480
data[id] = vm
473481
} else {
474482
process.env.NODE_ENV !== 'production' && _.warn(
475-
'Duplicate objects are not supported in v-repeat ' +
476-
'when using components or transitions.'
483+
'Duplicate objects found in v-repeat="' + this.expression + '": ' +
484+
JSON.stringify(data)
477485
)
478486
}
479487
} else {

0 commit comments

Comments
 (0)