Retrospring/app/javascript/retrospring/utilities/on.ts

7 lines
229 B
TypeScript

export function on(type: string, selector: string, callback: Function): void {
document.addEventListener(type, (event: Event) => {
if ((event.target as HTMLElement).matches(selector)) {
callback(event);
}
});
};