From: Evan You Date: Tue, 7 Sep 2021 16:25:00 +0000 (-0400) Subject: fix(runtime-dom): style patching shoud always preserve v-show display property X-Git-Tag: v3.2.10~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d53451583684c37bda7d30bff912216e1a58126f;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-dom): style patching shoud always preserve v-show display property close #4424 --- diff --git a/packages/runtime-dom/src/modules/style.ts b/packages/runtime-dom/src/modules/style.ts index 1084e5b2f8..69a608795d 100644 --- a/packages/runtime-dom/src/modules/style.ts +++ b/packages/runtime-dom/src/modules/style.ts @@ -5,18 +5,12 @@ type Style = string | Record | 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) { @@ -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$/