Skip to content

Commit 9fe26a6

Browse files
committed
handle recursive traces
1 parent 4b6913c commit 9fe26a6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/core/util/debug.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,29 @@ if (process.env.NODE_ENV !== 'production') {
5555
const generateComponentTrace = vm => {
5656
if (vm._isVue && vm.$parent && String.prototype.repeat) {
5757
const tree = []
58+
let currentRecursiveSequence = 0
5859
while (vm) {
60+
if (tree.length > 0) {
61+
const last = tree[tree.length - 1]
62+
if (last.constructor === vm.constructor) {
63+
currentRecursiveSequence++
64+
vm = vm.$parent
65+
continue
66+
} else if (currentRecursiveSequence > 0) {
67+
tree[tree.length - 1] = [last, currentRecursiveSequence]
68+
currentRecursiveSequence = 0
69+
}
70+
}
5971
tree.push(vm)
6072
vm = vm.$parent
6173
}
6274
return '\n\nfound in\n\n' + tree
6375
.map((vm, i) => `${
6476
i === 0 ? '---> ' : ' '.repeat(5 + i * 2)
6577
}${
66-
formatComponentName(vm)
78+
Array.isArray(vm)
79+
? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
80+
: formatComponentName(vm)
6781
}`)
6882
.join('\n')
6983
} else {

0 commit comments

Comments
 (0)