From 21fa830b9828a36b9360f6fbeb6ab5bfe0103742 Mon Sep 17 00:00:00 2001 From: liaoyinglong Date: Mon, 25 Apr 2022 22:59:44 +0800 Subject: [PATCH] feat: make sure has vnode --- src/utils/instance.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utils/instance.ts b/src/utils/instance.ts index 9a5be538..85e717ce 100644 --- a/src/utils/instance.ts +++ b/src/utils/instance.ts @@ -107,11 +107,13 @@ function updateTemplateRef(vm: ComponentInstance) { export function afterRender(vm: ComponentInstance) { const stack = [(vm as any)._vnode as VNode] while (stack.length) { - const vnode = stack.pop()! - if (vnode.context) updateTemplateRef(vnode.context) - if (vnode.children) { - for (let i = 0; i < vnode.children.length; ++i) { - stack.push(vnode.children[i]) + const vnode = stack.pop() + if (vnode) { + if (vnode.context) updateTemplateRef(vnode.context) + if (vnode.children) { + for (let i = 0; i < vnode.children.length; ++i) { + stack.push(vnode.children[i]) + } } } }