Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isOnce = Boolean(options.once)
}
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)
}
}
set (this: Style, newVal: string) {
const old = this[styleKey]
if (newVal) {
this._usedStyleProp.add(styleKey)
}
warn(
styleKey === 'style' && newVal.startsWith('data:image/'),
'直接在图片地址使用 data64 会造成渲染性能急剧下降,考虑在 CSS 类使用 base64 或其它替代方案。'
)
if (old !== newVal) {
this._value[styleKey] = newVal
this._element.enqueueUpdate({
path: `${this._element._path}.${Shortcuts.Style}`,
value: this.cssText
})
}
}
}