MCPcopy
hub / github.com/vuejs/core / getComponentTrace

Function getComponentTrace

packages/runtime-core/src/warning.ts:81–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79}
80
81export 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 */
111function formatTrace(trace: ComponentTraceStack): any[] {

Callers 1

warnFunction · 0.85

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected