Skip to content

Commit d534515

Browse files
committed
fix(runtime-dom): style patching shoud always preserve v-show display property
close #4424
1 parent b8653d3 commit d534515

File tree

1 file changed

+7
-7
lines changed
  • packages/runtime-dom/src/modules

1 file changed

+7
-7
lines changed

packages/runtime-dom/src/modules/style.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ type Style = string | Record<string, string | string[]> | null
55

66
export function patchStyle(el: Element, prev: Style, next: Style) {
77
const style = (el as HTMLElement).style
8+
const currentDisplay = style.display
89
if (!next) {
910
el.removeAttribute('style')
1011
} else if (isString(next)) {
1112
if (prev !== next) {
12-
const current = style.display
1313
style.cssText = next
14-
// indicates that the `display` of the element is controlled by `v-show`,
15-
// so we always keep the current `display` value regardless of the `style` value,
16-
// thus handing over control to `v-show`.
17-
if ('_vod' in el) {
18-
style.display = current
19-
}
2014
}
2115
} else {
2216
for (const key in next) {
@@ -30,6 +24,12 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
3024
}
3125
}
3226
}
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
32+
}
3333
}
3434

3535
const importantRE = /\s*!important$/

0 commit comments

Comments
 (0)