代码拉取完成,页面将自动刷新
var nestRE = /^(attrs|props|on|nativeOn|class|style|hook)$/
module.exports = function mergeJSXProps (objs) {
return objs.reduce(function (a, b) {
var aa, bb, key, nestedKey, temp
for (key in b) {
aa = a[key]
bb = b[key]
if (aa && nestRE.test(key)) {
// normalize class
if (key === 'class') {
if (typeof aa === 'string') {
temp = aa
a[key] = aa = {}
aa[temp] = true
}
if (typeof bb === 'string') {
temp = bb
b[key] = bb = {}
bb[temp] = true
}
}
if (key === 'on' || key === 'nativeOn' || key === 'hook') {
// merge functions
for (nestedKey in bb) {
aa[nestedKey] = mergeFn(aa[nestedKey], bb[nestedKey])
}
} else if (Array.isArray(aa)) {
a[key] = aa.concat(bb)
} else if (Array.isArray(bb)) {
a[key] = [aa].concat(bb)
} else {
for (nestedKey in bb) {
aa[nestedKey] = bb[nestedKey]
}
}
} else {
a[key] = b[key]
}
}
return a
}, {})
}
function mergeFn (a, b) {
return function () {
a && a.apply(this, arguments)
b && b.apply(this, arguments)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。