| 79 | } |
| 80 | |
| 81 | export function getComponentTrace(): ComponentTraceStack { |
| 82 | let currentVNode: VNode | null = stack[stack.length - 1] |
| 83 | if (!currentVNode) { |
| 84 | return [] |
| 85 | } |
| 86 | |
| 87 | // we can't just use the stack because it will be incomplete during updates |
| 88 | // that did not start from the root. Re-construct the parent chain using |
| 89 | // instance parent pointers. |
| 90 | const normalizedStack: ComponentTraceStack = [] |
| 91 | |
| 92 | while (currentVNode) { |
| 93 | const last = normalizedStack[0] |
| 94 | if (last && last.vnode === currentVNode) { |
| 95 | last.recurseCount++ |
| 96 | } else { |
| 97 | normalizedStack.push({ |
| 98 | vnode: currentVNode as ComponentVNode, |
| 99 | recurseCount: 0, |
| 100 | }) |
| 101 | } |
| 102 | const parentInstance: ComponentInternalInstance | null = |
| 103 | currentVNode.component && currentVNode.component.parent |
| 104 | currentVNode = parentInstance && parentInstance.vnode |
| 105 | } |
| 106 | |
| 107 | return normalizedStack |
| 108 | } |
| 109 | |
| 110 | /* v8 ignore start */ |
| 111 | function formatTrace(trace: ComponentTraceStack): any[] { |