From a0e2c1287466567d945e87496ce2f922f3dc6d8c Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 29 Apr 2020 14:41:06 -0400 Subject: [PATCH] fix(warning): always check for component instance presence when formatting traces --- packages/runtime-core/src/warning.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/runtime-core/src/warning.ts b/packages/runtime-core/src/warning.ts index 7b84d814419..aeeefe3988d 100644 --- a/packages/runtime-core/src/warning.ts +++ b/packages/runtime-core/src/warning.ts @@ -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 } @@ -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