perf: only patch string style when value has changed (#1310)

fix #1309
This commit is contained in:
underfin
2020-06-12 05:25:39 +08:00
committed by GitHub
parent 1f2926a33c
commit d4e9b19932
2 changed files with 19 additions and 1 deletions

View File

@@ -8,7 +8,9 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
if (!next) {
el.removeAttribute('style')
} else if (isString(next)) {
style.cssText = next
if (prev !== next) {
style.cssText = next
}
} else {
for (const key in next) {
setStyle(style, key, next[key] as string)