fix(utils): improve element.addEventListener (#3173)

This commit is contained in:
Aex 2021-09-01 17:38:54 +08:00 committed by GitHub
parent 614c09eead
commit 017eb705d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -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() {

View File

@ -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)
} }
} }