ソースを参照

fix(Transition): skip transition if el is hidden by v-show

daiwei 5 ヶ月 前
コミット
ec939946a6
1 ファイル変更9 行追加1 行削除
  1. 9 1
      packages/runtime-core/src/renderer.ts

+ 9 - 1
packages/runtime-core/src/renderer.ts

@@ -2054,7 +2054,9 @@ function baseCreateRenderer(
     const needTransition =
       moveType !== MoveType.REORDER &&
       shapeFlag & ShapeFlags.ELEMENT &&
-      transition
+      transition &&
+      // #14031 skip transition hooks if el is hidden by v-show
+      !isHiddenByVShow(vnode)
     if (needTransition) {
       if (moveType === MoveType.ENTER) {
         transition!.beforeEnter(el!)
@@ -2565,3 +2567,9 @@ export function invalidateMount(hooks: LifecycleHook): void {
       hooks[i].flags! |= SchedulerJobFlags.DISPOSED
   }
 }
+
+function isHiddenByVShow(vnode: VNode): boolean {
+  // @ts-expect-error vShow has this internal name
+  const vShowDir = vnode.dirs && vnode.dirs.find(dir => dir.name === 'show')
+  return !!(vShowDir && !vShowDir.value)
+}