Skip to content
This repository has been archived by the owner on Feb 18, 2023. It is now read-only.

Wrap an event handler so that it will e.preventDefault() for you when available. (i.e. also works if you call it directly)

License

Notifications You must be signed in to change notification settings

smallhelm/wrap-prevent-default

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wrap-prevent-default

Wrap an event handler so that it will e.preventDefault() for you when available. (i.e. also works if you call it directly)

var prevDflt = require("wrap-prevent-default");

var handler = prevDflt(function(event){
  console.log("I've been clicked!");
});

//attach it to the onclick handler somehow... (library and framework agnostic)
//  i.e. <a onclick="handler" ...>...
//when it's clicked it will preventDefault()

//you can also call it directly and it'll still work
handler();
  • this works as you would expect.
  • All arguments are passed on to your handler as you would expect.

License

MIT

About

Wrap an event handler so that it will e.preventDefault() for you when available. (i.e. also works if you call it directly)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published