Skip to content

Commit

Permalink
fix(runtime-dom): unify behavior for v-show + style display binding (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncanxyz committed Jan 11, 2024
1 parent dcc68ef commit cd419ae
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 @@ -7,6 +7,7 @@ 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
const isCssString = isString(next)
if (next && !isCssString) {
if (prev && !isString(prev)) {
Expand All @@ -20,7 +21,6 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
setStyle(style, key, next[key])
}
} else {
const currentDisplay = style.display
if (isCssString) {
if (prev !== next) {
// #9821
Expand All @@ -33,12 +33,12 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
} else if (prev) {
el.removeAttribute('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 (vShowOldKey in el) {
style.display = currentDisplay
}
}
// 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 (vShowOldKey in el) {
style.display = currentDisplay
}
}

Expand Down

0 comments on commit cd419ae

Please sign in to comment.