Skip to content

Commit

Permalink
fix(runtime-dom): style patching shoud always preserve v-show display…
Browse files Browse the repository at this point in the history
… property

close #4424
  • Loading branch information
yyx990803 committed Sep 7, 2021
1 parent b8653d3 commit d534515
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/runtime-dom/src/modules/style.ts
Expand Up @@ -5,18 +5,12 @@ type Style = string | Record<string, string | string[]> | null

export function patchStyle(el: Element, prev: Style, next: Style) {
const style = (el as HTMLElement).style
const currentDisplay = style.display
if (!next) {
el.removeAttribute('style')
} else if (isString(next)) {
if (prev !== next) {
const current = style.display
style.cssText = next
// indicates that the `display` of the element is controlled by `v-show`,
// so we always keep the current `display` value regardless of the `style` value,
// thus handing over control to `v-show`.
if ('_vod' in el) {
style.display = current
}
}
} else {
for (const key in next) {
Expand All @@ -30,6 +24,12 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
}
}
}
// indicates that the `display` of the element is controlled by `v-show`,
// so we always keep the current `display` value regardless of the `style` value,
// thus handing over control to `v-show`.
if ('_vod' in el) {
style.display = currentDisplay
}
}

const importantRE = /\s*!important$/
Expand Down

0 comments on commit d534515

Please sign in to comment.