浏览代码

fix(runtime-core): do not call transition enter hooks when mounting in suspense (#1588)

fix #1583
underfin 5 年之前
父节点
当前提交
246ec5c594
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      packages/runtime-core/src/renderer.ts

+ 5 - 2
packages/runtime-core/src/renderer.ts

@@ -736,14 +736,17 @@ function baseCreateRenderer(
     }
 
     hostInsert(el, container, anchor)
+    // #1583 For inside suspense case, enter hook should call when suspense resolved
+    const needCallTransitionHooks =
+      !parentSuspense && transition && !transition.persisted
     if (
       (vnodeHook = props && props.onVnodeMounted) ||
-      (transition && !transition.persisted) ||
+      needCallTransitionHooks ||
       dirs
     ) {
       queuePostRenderEffect(() => {
         vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode)
-        transition && !transition.persisted && transition.enter(el)
+        needCallTransitionHooks && transition!.enter(el)
         dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted')
       }, parentSuspense)
     }