Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _stopPropagation (event: TaroEvent) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
let target = this
// eslint-disable-next-line no-cond-assign
while ((target = target.parentNode as this)) {
const listeners = target.__handlers[event.type]
if (!isArray(listeners)) {
continue
}
for (let i = listeners.length; i--;) {
const l = listeners[i]
l._stop = true
}
}
}
}
if (isOnce) {
const wrapper = function () {
handler.apply(this, arguments) // this 指向 Element
this.removeEventListener(type, wrapper)
}
this.addEventListener(type, wrapper, {
...(options as AddEventListenerOptions),
once: false
})
return
}
warn(isCapture, 'The event capture feature is unimplemented.')
if (isArray(handlers)) {
handlers.push(handler)
} else {
this.__handlers[type] = [handler]
}
}
public removeEventListener (type: string, handler: EventHandler) {
type = type.toLowerCase()
if (handler == null) {
return
}
const handlers = this.__handlers[type]
if (!isArray(handlers)) {
return
}
const index = handlers.indexOf(handler)
warn(index === -1, `事件: '${type}' 没有注册在 DOM 中,因此不会被移除。`)
handlers.splice(index, 1)
}
}
function getValue (key: string) {
if (Adapter.type === BUILD_TYPES.SWAN && isArray(swanSpecialAttrs[nodeName]) && swanSpecialAttrs[nodeName].includes(key)) {
return `= ${attrs[key]} =`
}
return `{ ${attrs[key]} }`
}
return Object.keys(attrs)