|
|
@@ -11,11 +11,18 @@ function createStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
|
|
}
|
|
|
const elm = vnode.elm
|
|
|
const staticStyle = vnode.data.staticStyle
|
|
|
+ const supportBatchUpdate = typeof elm.setStyles === 'function'
|
|
|
+ const batchedStyles = {}
|
|
|
for (const name in staticStyle) {
|
|
|
if (staticStyle[name]) {
|
|
|
- elm.setStyle(normalize(name), staticStyle[name])
|
|
|
+ supportBatchUpdate
|
|
|
+ ? (batchedStyles[normalize(name)] = staticStyle[name])
|
|
|
+ : elm.setStyle(normalize(name), staticStyle[name])
|
|
|
}
|
|
|
}
|
|
|
+ if (supportBatchUpdate) {
|
|
|
+ elm.setStyles(batchedStyles)
|
|
|
+ }
|
|
|
updateStyle(oldVnode, vnode)
|
|
|
}
|
|
|
|
|
|
@@ -41,14 +48,23 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
|
|
style = vnode.data.style = extend({}, style)
|
|
|
}
|
|
|
|
|
|
+ const supportBatchUpdate = typeof elm.setStyles === 'function'
|
|
|
+ const batchedStyles = {}
|
|
|
for (name in oldStyle) {
|
|
|
if (!style[name]) {
|
|
|
- elm.setStyle(normalize(name), '')
|
|
|
+ supportBatchUpdate
|
|
|
+ ? (batchedStyles[normalize(name)] = '')
|
|
|
+ : elm.setStyle(normalize(name), '')
|
|
|
}
|
|
|
}
|
|
|
for (name in style) {
|
|
|
cur = style[name]
|
|
|
- elm.setStyle(normalize(name), cur)
|
|
|
+ supportBatchUpdate
|
|
|
+ ? (batchedStyles[normalize(name)] = cur)
|
|
|
+ : elm.setStyle(normalize(name), cur)
|
|
|
+ }
|
|
|
+ if (supportBatchUpdate) {
|
|
|
+ elm.setStyles(batchedStyles)
|
|
|
}
|
|
|
}
|
|
|
|