Skip to content

fix(runtime-dom): fix an update error when the style changed from str… #5362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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