types: add stricter types

This commit is contained in:
Michael Brevard 2024-06-15 01:24:36 +03:00 committed by GitHub
parent 76f2f5dc4a
commit d5bd5f8392
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -102,7 +102,7 @@ export const createLazyEventClientPage = (componentLoader: Component) => {
const nuxt = useNuxtApp()
const instance = getCurrentInstance()!
const isTriggered = ref(false)
const events: string[] = attrs.loader ?? ['mouseover']
const events: string[] = attrs.loader as string[] ?? ['mouseover']
const registeredEvents: (() => void)[] = []
onMounted(() => {
@ -112,8 +112,8 @@ export const createLazyEventClientPage = (componentLoader: Component) => {
registeredEvents.forEach((remove) => remove())
eventsMapper.delete(instance)
}
instance.vnode.el.addEventListener(event, handler)
registeredEvents.push(() => instance.vnode.el.removeEventListener(event, handler))
instance.vnode.el?.addEventListener(event, handler)
registeredEvents.push(() => instance.vnode.el?.removeEventListener(event, handler))
})
eventsMapper.set(instance, registeredEvents)
})
@ -124,4 +124,4 @@ export const createLazyEventClientPage = (componentLoader: Component) => {
return () => isTriggered.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createVNode(createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1)) : null
}
})
}
}