Skip to content

Commit a0e2c12

Browse files
committed
fix(warning): always check for component instance presence when formatting traces
1 parent 5f89674 commit a0e2c12

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/runtime-core/src/warning.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ function getComponentTrace(): ComponentTraceStack {
8989
recurseCount: 0
9090
})
9191
}
92-
const parentInstance: ComponentInternalInstance | null = currentVNode.component!
93-
.parent
92+
const parentInstance: ComponentInternalInstance | null =
93+
currentVNode.component && currentVNode.component.parent
9494
currentVNode = parentInstance && parentInstance.vnode
9595
}
9696

@@ -108,7 +108,7 @@ function formatTrace(trace: ComponentTraceStack): any[] {
108108
function formatTraceEntry({ vnode, recurseCount }: TraceEntry): any[] {
109109
const postfix =
110110
recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``
111-
const isRoot = vnode.component!.parent == null
111+
const isRoot = vnode.component ? vnode.component.parent == null : false
112112
const open = ` at <${formatComponentName(vnode.type, isRoot)}`
113113
const close = `>` + postfix
114114
return vnode.props

0 commit comments

Comments
 (0)