refactor(core): [CORE-20] type entry and converge initialization

This commit is contained in:
Harvey Zhao committed 2026-09-11 16:07:06 +08:00
1 parent ccf77c4ed2
commit ee895a558f
100 files changed
+33854 -839

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
interface EventPathSource {
target: EventTarget | null
composedPath?: () => EventTarget[]
}
export function getComposedPath(event: EventPathSource): EventTarget[] {
if (event.composedPath)
return event.composedPath()
const path: EventTarget[] = []
let node = event.target
while (node) {
path.push(node)
node = (node as EventTarget & { parentNode?: EventTarget | null }).parentNode ?? null
}
if (typeof window !== 'undefined' && !path.includes(window))
path.push(window)
return path
}
export function includeFromEvent(event: EventPathSource, target: EventTarget | null | undefined): boolean {
return getComposedPath(event).includes(target as EventTarget)
}