return stopper function as the result of record

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent efa7a8fa1b
commit 09f30d2a81
3 changed files with 105 additions and 93 deletions

View File

@@ -11,8 +11,9 @@ export function on(
fn: EventListenerOrEventListenerObject,
target: Document | Window = document,
): listenerHandler {
target.addEventListener(type, fn, { capture: true, passive: true });
return () => target.removeEventListener(type, fn);
const options = { capture: true, passive: true };
target.addEventListener(type, fn, options);
return () => target.removeEventListener(type, fn, options);
}
export const mirror: Mirror = {