fix: avoid setting another mounted if instance is registered

This commit is contained in:
Michael Brevard 2024-06-15 17:04:19 +03:00 committed by GitHub
parent 5d5432cba7
commit 3727a435b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 11 deletions

View File

@ -105,6 +105,7 @@ export const createLazyEventClientPage = (componentLoader: Component) => {
const events: string[] = attrs.loader as string[] ?? ['mouseover']
const registeredEvents: (() => void)[] = []
if (!eventsMapper.has(instance)) {
onMounted(() => {
events.forEach((event) => {
const handler = () => {
@ -117,6 +118,7 @@ export const createLazyEventClientPage = (componentLoader: Component) => {
})
eventsMapper.set(instance, registeredEvents)
})
}
onBeforeUnmount(() => {
registeredEvents?.forEach(remove => remove())
eventsMapper.delete(instance)