]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: parent chain error when root is functional
authorEvan You <yyx990803@gmail.com>
Sun, 28 Oct 2018 16:08:20 +0000 (12:08 -0400)
committerEvan You <yyx990803@gmail.com>
Sun, 28 Oct 2018 16:08:20 +0000 (12:08 -0400)
packages/runtime-core/src/componentUtils.ts

index 52fea6c0b110f71a0cb008e467d1435aa8f936c1..a3e218b29cc12bdf2bd8eee9052b77096072915d 100644 (file)
@@ -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
   }