diff --git a/packages/runtime-dom/src/modules/style.ts b/packages/runtime-dom/src/modules/style.ts index a9cc67ba5e2..22a52ba83f7 100644 --- a/packages/runtime-dom/src/modules/style.ts +++ b/packages/runtime-dom/src/modules/style.ts @@ -7,16 +7,20 @@ export function patchStyle(el: Element, prev: Style, next: Style) { const style = (el as HTMLElement).style const isCssString = isString(next) if (next && !isCssString) { - for (const key in next) { - setStyle(style, key, next[key]) - } - if (prev && !isString(prev)) { - for (const key in prev) { - if (next[key] == null) { - setStyle(style, key, '') + if (prev) { + if (isString(prev)) { + style.cssText = '' + } else { + for (const key in prev) { + if (next[key] == null) { + setStyle(style, key, ''); + } } } } + for (const key in next) { + setStyle(style, key, next[key]) + } } else { const currentDisplay = style.display if (isCssString) {