|
|
@@ -1,11 +1,15 @@
|
|
|
-// TODO:
|
|
|
-// - include prefix sniffing of v-bind:style
|
|
|
+import { extend, isArray } from '../../../shared/util'
|
|
|
|
|
|
function updateStyle (oldVnode, vnode) {
|
|
|
let cur, name
|
|
|
const elm = vnode.elm
|
|
|
const oldStyle = oldVnode.data.style || {}
|
|
|
- const style = vnode.data.style || {}
|
|
|
+ let style = vnode.data.style || {}
|
|
|
+
|
|
|
+ // handle array syntax
|
|
|
+ if (isArray(style)) {
|
|
|
+ style = vnode.data.style = toObject(style)
|
|
|
+ }
|
|
|
|
|
|
for (name in oldStyle) {
|
|
|
if (!style[name]) {
|
|
|
@@ -20,6 +24,16 @@ function updateStyle (oldVnode, vnode) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function toObject (arr) {
|
|
|
+ const res = arr[0] || {}
|
|
|
+ for (var i = 1; i < arr.length; i++) {
|
|
|
+ if (arr[i]) {
|
|
|
+ extend(res, arr[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|
|
|
+
|
|
|
export default {
|
|
|
create: updateStyle,
|
|
|
update: updateStyle
|