Skip to content

Commit

Permalink
fix(warning): always check for component instance presence when forma…
Browse files Browse the repository at this point in the history
…tting traces
  • Loading branch information
yyx990803 committed Apr 29, 2020
1 parent 5f89674 commit a0e2c12
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/runtime-core/src/warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function getComponentTrace(): ComponentTraceStack {
recurseCount: 0
})
}
const parentInstance: ComponentInternalInstance | null = currentVNode.component!
.parent
const parentInstance: ComponentInternalInstance | null =
currentVNode.component && currentVNode.component.parent
currentVNode = parentInstance && parentInstance.vnode
}

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

0 comments on commit a0e2c12

Please sign in to comment.