@@ -5,14 +5,8 @@ type Style = string | Record<string, string | string[]> | null
5
5
6
6
export function patchStyle ( el : Element , prev : Style , next : Style ) {
7
7
const style = ( el as HTMLElement ) . style
8
- const currentDisplay = style . display
9
- if ( ! next ) {
10
- el . removeAttribute ( 'style' )
11
- } else if ( isString ( next ) ) {
12
- if ( prev !== next ) {
13
- style . cssText = next
14
- }
15
- } else {
8
+ const isCssString = isString ( next )
9
+ if ( next && ! isCssString ) {
16
10
for ( const key in next ) {
17
11
setStyle ( style , key , next [ key ] )
18
12
}
@@ -23,12 +17,21 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
23
17
}
24
18
}
25
19
}
26
- }
27
- // indicates that the `display` of the element is controlled by `v-show`,
28
- // so we always keep the current `display` value regardless of the `style` value,
29
- // thus handing over control to `v-show`.
30
- if ( '_vod' in el ) {
31
- style . display = currentDisplay
20
+ } else {
21
+ const currentDisplay = style . display
22
+ if ( isCssString ) {
23
+ if ( prev !== next ) {
24
+ style . cssText = next as string
25
+ }
26
+ } else if ( prev ) {
27
+ el . removeAttribute ( 'style' )
28
+ }
29
+ // indicates that the `display` of the element is controlled by `v-show`,
30
+ // so we always keep the current `display` value regardless of the `style`
31
+ // value, thus handing over control to `v-show`.
32
+ if ( '_vod' in el ) {
33
+ style . display = currentDisplay
34
+ }
32
35
}
33
36
}
34
37
0 commit comments