Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions src/platforms/weex/runtime/modules/attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,27 @@ function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) {
attrs = vnode.data.attrs = extend({}, attrs)
}

const supportBatchUpdate = typeof elm.setAttrs === 'function'
const batchedAttrs = {}
for (key in attrs) {
cur = attrs[key]
old = oldAttrs[key]
if (old !== cur) {
elm.setAttr(key, cur)
supportBatchUpdate
? (batchedAttrs[key] = cur)
: elm.setAttr(key, cur)
}
}
for (key in oldAttrs) {
if (attrs[key] == null) {
elm.setAttr(key)
supportBatchUpdate
? (batchedAttrs[key] = undefined)
: elm.setAttr(key)
}
}
if (supportBatchUpdate) {
elm.setAttrs(batchedAttrs)
}
}

export default {
Expand Down
8 changes: 6 additions & 2 deletions src/platforms/weex/runtime/modules/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
}

const style = getStyle(oldClassList, classList, ctx)
for (const key in style) {
el.setStyle(key, style[key])
if (typeof el.setStyles === 'function') {
el.setStyles(style)
} else {
for (const key in style) {
el.setStyle(key, style[key])
}
}
}

Expand Down
22 changes: 19 additions & 3 deletions src/platforms/weex/runtime/modules/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/platforms/weex/runtime/modules/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@ function enter (_, vnode) {
beforeEnterHook && beforeEnterHook(el)

if (startState) {
for (const key in startState) {
el.setStyle(key, startState[key])
if (typeof el.setStyles === 'function') {
el.setStyles(startState)
} else {
for (const key in startState) {
el.setStyle(key, startState[key])
}
}
}

Expand Down