refactor: 빌드 오류 수정

This commit is contained in:
“hyeonggkim”
2026-01-29 21:32:33 +09:00
parent a9c0182f5e
commit ee68a02751

View File

@@ -631,42 +631,43 @@
{ immediate: true }, { immediate: true },
) )
// 이벤트 위임 핸들러
const onDelegatedClick = (e: MouseEvent) => {
const target = e.target as HTMLElement | null
const el =
(target?.closest?.('[data-action]') as HTMLElement | null) ?? null
handleCustomAction(el)
}
// onMounted에서 초기화 코드 실행 (CSR에서만) // onMounted에서 초기화 코드 실행 (CSR에서만)
onMounted(() => { if (import.meta.client) {
if (!import.meta.client) return onMounted(() => {
const container = customContainerRef.value
if (!container) return
const container = customContainerRef.value // fnCustomAction, fnCustomLog 전역 등록
if (!container) return window.fnCustomAction = handleCustomAction
window.fnCustomLog = handleCustomLog
// onclick="fnCustomAction(this)", fnCustomLog(this) 지원 (CSR에서만) // 이벤트 위임 등록
;window.fnCustomAction = handleCustomAction container.addEventListener('click', onDelegatedClick)
;window.fnCustomLog = handleCustomLog
// onclick을 못 쓰는 케이스 대비: 이벤트 위임도 같이 지원
const onDelegatedClick = (e: MouseEvent) => {
const target = e.target as HTMLElement | null
const el =
(target?.closest?.('[data-action], [data-log]') as HTMLElement | null) ??
null
handleCustomAction(el)
}
container.addEventListener('click', onDelegatedClick)
onBeforeUnmount(() => {
container.removeEventListener('click', onDelegatedClick)
}) })
})
onBeforeUnmount(() => { onBeforeUnmount(() => {
if (!import.meta.client) return const container = customContainerRef.value
const w = window as any if (container) {
if (w.fnCustomAction === handleCustomAction) { container.removeEventListener('click', onDelegatedClick)
delete w.fnCustomAction }
}
if (w.fnCustomLog === handleCustomLog) { const w = window as any
delete w.fnCustomLog if (w.fnCustomAction === handleCustomAction) {
} delete w.fnCustomAction
}) }
if (w.fnCustomLog === handleCustomLog) {
delete w.fnCustomLog
}
})
}
</script> </script>
<template> <template>