Skip to content

Commit 75da557

Browse files
committed
chore(vShow): simplify fragment handling logic
1 parent f37b6af commit 75da557

File tree

1 file changed

+3
-6
lines changed
  • packages/runtime-vapor/src/directives

1 file changed

+3
-6
lines changed

packages/runtime-vapor/src/directives/vShow.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { isVaporComponent } from '../component'
1111
import type { Block, TransitionBlock } from '../block'
1212
import { isArray } from '@vue/shared'
1313
import { isHydrating, logMismatchError } from '../dom/hydration'
14-
import { DynamicFragment, VaporFragment } from '../fragment'
14+
import { DynamicFragment, VaporFragment, isFragment } from '../fragment'
1515

1616
export function applyVShow(target: Block, source: () => any): void {
1717
if (isVaporComponent(target)) {
@@ -47,21 +47,18 @@ function setDisplay(target: Block, value: unknown): void {
4747
if (target.length === 0) return
4848
if (target.length === 1) return setDisplay(target[0], value)
4949
}
50-
if (target instanceof DynamicFragment) {
51-
return setDisplay(target.nodes, value)
52-
}
53-
if (target instanceof VaporFragment && target.insert) {
50+
if (isFragment(target)) {
5451
return setDisplay(target.nodes, value)
5552
}
5653

57-
const { $transition } = target as TransitionBlock
5854
if (target instanceof Element) {
5955
const el = target as VShowElement
6056
if (!(vShowOriginalDisplay in el)) {
6157
el[vShowOriginalDisplay] =
6258
el.style.display === 'none' ? '' : el.style.display
6359
}
6460

61+
const { $transition } = target as TransitionBlock
6562
if ($transition) {
6663
if (value) {
6764
$transition.beforeEnter(target)

0 commit comments

Comments
 (0)