mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-21 02:50:11 +08:00
fix(utils): improve element.addEventListener (#3173)
This commit is contained in:
parent
614c09eead
commit
017eb705d3
@ -159,9 +159,8 @@ export default defineComponent({
|
|||||||
|
|
||||||
const triggerVnode = ref<Nullable<ComponentPublicInstance>>(null)
|
const triggerVnode = ref<Nullable<ComponentPublicInstance>>(null)
|
||||||
const triggerElm = computed<Nullable<HTMLButtonElement>>(() => {
|
const triggerElm = computed<Nullable<HTMLButtonElement>>(() => {
|
||||||
const _: any =
|
const _: any = (triggerVnode.value?.$refs.triggerRef as HTMLElement)?.children[0]
|
||||||
(triggerVnode.value?.$refs.triggerRef as HTMLElement)?.children[0] ?? {}
|
return !props.splitButton ? _ : _?.children?.[1]
|
||||||
return !props.splitButton ? _ : _.children?.[1]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
|
@ -17,7 +17,7 @@ export const on = function(
|
|||||||
useCapture = false,
|
useCapture = false,
|
||||||
): void {
|
): void {
|
||||||
if (element && event && handler) {
|
if (element && event && handler) {
|
||||||
element.addEventListener(event, handler, useCapture)
|
element?.addEventListener(event, handler, useCapture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ export const off = function(
|
|||||||
useCapture = false,
|
useCapture = false,
|
||||||
): void {
|
): void {
|
||||||
if (element && event && handler) {
|
if (element && event && handler) {
|
||||||
element.removeEventListener(event, handler, useCapture)
|
element?.removeEventListener(event, handler, useCapture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user