11import { capitalize , hyphenate , isArray , isString } from '@vue/shared'
22import { camelize , warn } from '@vue/runtime-core'
3- import { vShowOriginalDisplay } from '../directives/vShow'
3+ import {
4+ type VShowElement ,
5+ vShowHidden ,
6+ vShowOriginalDisplay ,
7+ } from '../directives/vShow'
48import { CSS_VAR_TEXT } from '../helpers/useCssVars'
59
610type Style = string | Record < string , string | string [ ] > | null
@@ -10,7 +14,6 @@ const displayRE = /(^|;)\s*display\s*:/
1014export function patchStyle ( el : Element , prev : Style , next : Style ) {
1115 const style = ( el as HTMLElement ) . style
1216 const isCssString = isString ( next )
13- const currentDisplay = style . display
1417 let hasControlledDisplay = false
1518 if ( next && ! isCssString ) {
1619 if ( prev ) {
@@ -50,12 +53,14 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
5053 el . removeAttribute ( 'style' )
5154 }
5255 }
53- // indicates that the `display` of the element is controlled by `v-show`,
54- // so we always keep the current `display` value regardless of the `style`
55- // value, thus handing over control to `v-show`.
56+ // indicates the element also has `v-show`.
5657 if ( vShowOriginalDisplay in el ) {
58+ // make v-show respect the current v-bind style display when shown
5759 el [ vShowOriginalDisplay ] = hasControlledDisplay ? style . display : ''
58- style . display = currentDisplay
60+ // if v-show is in hidden state, v-show has higher priority
61+ if ( ( el as VShowElement ) [ vShowHidden ] ) {
62+ style . display = 'none'
63+ }
5964 }
6065}
6166
0 commit comments