@@ -7,6 +7,8 @@ interface VShowElement extends HTMLElement {
7
7
[ vShowOldKey ] : string
8
8
}
9
9
10
+ const resolvedPromise = Promise . resolve ( )
11
+
10
12
export const vShow : ObjectDirective < VShowElement > & { name ?: 'show' } = {
11
13
beforeMount ( el , { value } , { transition } ) {
12
14
el [ vShowOldKey ] = el . style . display === 'none' ? '' : el . style . display
@@ -24,21 +26,24 @@ export const vShow: ObjectDirective<VShowElement> & { name?: 'show' } = {
24
26
updated ( el , { value, oldValue } , { transition } ) {
25
27
if (
26
28
! value === ! oldValue &&
27
- ( el . style . display === el [ vShowOldKey ] || ! value )
29
+ ( el . style . display === el [ vShowOldKey ] || ( ! value && transition ) )
28
30
)
29
31
return
30
32
if ( transition ) {
31
33
if ( value ) {
32
34
transition . beforeEnter ( el )
33
- setDisplay ( el , true )
35
+ postSetDisplay ( el , true )
34
36
transition . enter ( el )
35
37
} else {
36
38
transition . leave ( el , ( ) => {
37
- setDisplay ( el , false )
39
+ postSetDisplay ( el , false )
38
40
} )
39
41
}
40
42
} else {
41
- setDisplay ( el , value )
43
+ // #10038
44
+ // when multi vShow be applied to the same element
45
+ // and the sync setDisplay will impact other vShow
46
+ postSetDisplay ( el , value )
42
47
}
43
48
} ,
44
49
beforeUnmount ( el , { value } ) {
@@ -54,6 +59,12 @@ function setDisplay(el: VShowElement, value: unknown): void {
54
59
el . style . display = value ? el [ vShowOldKey ] : 'none'
55
60
}
56
61
62
+ function postSetDisplay ( el : VShowElement , value : unknown ) : void {
63
+ resolvedPromise . then ( ( ) => {
64
+ setDisplay ( el , value )
65
+ } )
66
+ }
67
+
57
68
// SSR vnode transforms, only used when user includes client-oriented render
58
69
// function in SSR
59
70
export function initVShowForSSR ( ) {
0 commit comments