Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
}
if (isObject(value)) {
for (const i in value) {
if (!oldValue || value[i] !== (oldValue as StyleValue)[i]) {
setStyle(style, i, value[i])
}
}
}
}
} else if (isEventName(name)) {
setEvent(dom, name, value, oldValue)
} else if (
!isFunction(value) &&
name !== 'dangerouslySetInnerHTML' // TODO: 实现 innerHTML
) {
if (value == null) {
dom.removeAttribute(name)
} else {
dom.setAttribute(name, value as string)
}
}
}
if (path.endsWith(Shortcuts.Childnodes)) {
resetPaths.add(path)
}
data[path] = value
}
for (const path in data) {
resetPaths.forEach(p => {
// 已经重置了数组,就不需要分别再设置了
if (path.includes(p) && path !== p) {
delete data[path]
}
})
const value = data[path]
if (isFunction(value)) {
data[path] = value()
}
}
ctx.setData(data, () => {
this.pendingUpdate = false
})
}, 1)
}
onShow (options: unknown) {
if (appInstance != null && isFunction(appInstance.$options.onShow)) {
appInstance.$options.onShow.call(appInstance, options)
}
}
onHide (options: unknown) {
if (appInstance != null && isFunction(appInstance.$options.onHide)) {
appInstance.$options.onHide.call(appInstance, options)
}
}
onHide (options: unknown) {
const app = ref.current
if (app != null && isFunction(app.componentDidHide)) {
app.componentDidHide(options)
}
}
function setEvent (dom: TaroElement, name: string, value: unknown, oldValue?: unknown) {
const isCapture = name.endsWith('Capture')
let eventName = name.toLowerCase().slice(2)
if (isCapture) {
eventName = eventName.slice(0, -7)
}
if (eventName === 'click') {
eventName = 'tap'
}
if (isFunction(value)) {
if (!oldValue) {
dom.addEventListener(eventName, eventProxy, isCapture)
}
let events = listeners[dom.uid]
if (!events) {
events = listeners[dom.uid] = {}
}
events[eventName] = value
} else {
dom.removeEventListener(eventName, eventProxy)
const events = listeners[dom.uid]
delete events[eventName]
}
}
onShow (options: unknown) {
const app = ref.current
if (app != null && isFunction(app.componentDidShow)) {
app.componentDidShow(options)
}
}