Skip to content

Commit

Permalink
fix(runtime-dom): fix an update error when the style changed from str…
Browse files Browse the repository at this point in the history
…ing to object
  • Loading branch information
hg3w committed Feb 5, 2022
1 parent 60cf175 commit ea98cfe
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/runtime-dom/src/modules/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ea98cfe

Please sign in to comment.