mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
types: add stricter types
This commit is contained in:
parent
76f2f5dc4a
commit
d5bd5f8392
@ -102,7 +102,7 @@ export const createLazyEventClientPage = (componentLoader: Component) => {
|
|||||||
const nuxt = useNuxtApp()
|
const nuxt = useNuxtApp()
|
||||||
const instance = getCurrentInstance()!
|
const instance = getCurrentInstance()!
|
||||||
const isTriggered = ref(false)
|
const isTriggered = ref(false)
|
||||||
const events: string[] = attrs.loader ?? ['mouseover']
|
const events: string[] = attrs.loader as string[] ?? ['mouseover']
|
||||||
|
|
||||||
const registeredEvents: (() => void)[] = []
|
const registeredEvents: (() => void)[] = []
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -112,8 +112,8 @@ export const createLazyEventClientPage = (componentLoader: Component) => {
|
|||||||
registeredEvents.forEach((remove) => remove())
|
registeredEvents.forEach((remove) => remove())
|
||||||
eventsMapper.delete(instance)
|
eventsMapper.delete(instance)
|
||||||
}
|
}
|
||||||
instance.vnode.el.addEventListener(event, handler)
|
instance.vnode.el?.addEventListener(event, handler)
|
||||||
registeredEvents.push(() => instance.vnode.el.removeEventListener(event, handler))
|
registeredEvents.push(() => instance.vnode.el?.removeEventListener(event, handler))
|
||||||
})
|
})
|
||||||
eventsMapper.set(instance, registeredEvents)
|
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
|
return () => isTriggered.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createVNode(createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1)) : null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user