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

View File

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