Skip to content

Instantly share code, notes, and snippets.

@SpenceDiNicolantonio
Last active May 6, 2024 20:46
Show Gist options
  • Save SpenceDiNicolantonio/12d5d2057fc677bc9d57540057566da0 to your computer and use it in GitHub Desktop.
Save SpenceDiNicolantonio/12d5d2057fc677bc9d57540057566da0 to your computer and use it in GitHub Desktop.
Prevent Default directive #svelte #typescript #directive
export default function preventDefault<T extends Event>(fn: (e: T) => void | Promise<void>) {
return function (this: (e: T) => void, event: T) {
event.preventDefault();
fn.call(this, event);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment