From 01bb8d189482084291248a8deba3c94f6a684c2c Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 28 Oct 2018 12:08:20 -0400 Subject: [PATCH] fix: parent chain error when root is functional --- packages/runtime-core/src/componentUtils.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/runtime-core/src/componentUtils.ts b/packages/runtime-core/src/componentUtils.ts index 52fea6c0..a3e218b2 100644 --- a/packages/runtime-core/src/componentUtils.ts +++ b/packages/runtime-core/src/componentUtils.ts @@ -77,18 +77,17 @@ export function initializeComponentInstance(instance: ComponentInstance) { // parent chain management if (currentContextVNode !== null) { // locate first non-functional parent - while ( - currentContextVNode !== null && - currentContextVNode.flags & VNodeFlags.COMPONENT_FUNCTIONAL && - currentContextVNode.contextVNode !== null - ) { - currentContextVNode = currentContextVNode.contextVNode as any + while (currentContextVNode !== null) { + if ((currentContextVNode.flags & VNodeFlags.COMPONENT_STATEFUL) > 0) { + const parentComponent = (currentContextVNode as VNode) + .children as ComponentInstance + instance.$parent = parentComponent.$proxy + instance.$root = parentComponent.$root + parentComponent.$children.push(proxy) + break + } + currentContextVNode = currentContextVNode.contextVNode } - const parentComponent = (currentContextVNode as VNode) - .children as ComponentInstance - instance.$parent = parentComponent.$proxy - instance.$root = parentComponent.$root - parentComponent.$children.push(proxy) } else { instance.$root = proxy }