2018-10-17 03:47:51 +08:00
|
|
|
import { isString } from '@vue/shared'
|
|
|
|
|
2019-05-26 15:19:44 +08:00
|
|
|
export function patchStyle(el: any, prev: any, next: any) {
|
2018-09-19 23:35:38 +08:00
|
|
|
const { style } = el
|
|
|
|
if (!next) {
|
|
|
|
el.removeAttribute('style')
|
2018-10-17 03:47:51 +08:00
|
|
|
} else if (isString(next)) {
|
2018-09-19 23:35:38 +08:00
|
|
|
style.cssText = next
|
|
|
|
} else {
|
2018-09-25 07:11:14 +08:00
|
|
|
for (const key in next) {
|
2019-01-23 05:03:37 +08:00
|
|
|
style[key] = next[key]
|
2018-09-19 23:35:38 +08:00
|
|
|
}
|
2018-10-17 03:47:51 +08:00
|
|
|
if (prev && !isString(prev)) {
|
2018-09-19 23:35:38 +08:00
|
|
|
for (const key in prev) {
|
2018-09-25 07:11:14 +08:00
|
|
|
if (!next[key]) {
|
2018-09-25 06:51:58 +08:00
|
|
|
style[key] = ''
|
2018-09-19 23:35:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|