]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore(vShow): simplify fragment handling logic
authordaiwei <daiwei521@126.com>
Wed, 26 Nov 2025 08:51:40 +0000 (16:51 +0800)
committerdaiwei <daiwei521@126.com>
Wed, 26 Nov 2025 08:51:40 +0000 (16:51 +0800)
packages/runtime-vapor/src/directives/vShow.ts

index 39d4cb55d7cda52acb8effb12a3620504557d1f4..1d522b00b1715375fae2c111877f645c7f6c5951 100644 (file)
@@ -11,7 +11,7 @@ import { isVaporComponent } from '../component'
 import type { Block, TransitionBlock } from '../block'
 import { isArray } from '@vue/shared'
 import { isHydrating, logMismatchError } from '../dom/hydration'
-import { DynamicFragment, VaporFragment } from '../fragment'
+import { DynamicFragment, VaporFragment, isFragment } from '../fragment'
 
 export function applyVShow(target: Block, source: () => any): void {
   if (isVaporComponent(target)) {
@@ -47,14 +47,10 @@ function setDisplay(target: Block, value: unknown): void {
     if (target.length === 0) return
     if (target.length === 1) return setDisplay(target[0], value)
   }
-  if (target instanceof DynamicFragment) {
-    return setDisplay(target.nodes, value)
-  }
-  if (target instanceof VaporFragment && target.insert) {
+  if (isFragment(target)) {
     return setDisplay(target.nodes, value)
   }
 
-  const { $transition } = target as TransitionBlock
   if (target instanceof Element) {
     const el = target as VShowElement
     if (!(vShowOriginalDisplay in el)) {
@@ -62,6 +58,7 @@ function setDisplay(target: Block, value: unknown): void {
         el.style.display === 'none' ? '' : el.style.display
     }
 
+    const { $transition } = target as TransitionBlock
     if ($transition) {
       if (value) {
         $transition.beforeEnter(target)