Last active
May 6, 2024 20:46
-
-
Save SpenceDiNicolantonio/12d5d2057fc677bc9d57540057566da0 to your computer and use it in GitHub Desktop.
Prevent Default directive #svelte #typescript #directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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