Skip to content

Instantly share code, notes, and snippets.

@cdata
Created October 7, 2015 22:23
Show Gist options
  • Select an option

  • Save cdata/e9f1775faeeb3561e587 to your computer and use it in GitHub Desktop.

Select an option

Save cdata/e9f1775faeeb3561e587 to your computer and use it in GitHub Desktop.
// Throw on prevent default:
var origPrevDef = KeyboardEvent.prototype.preventDefault;
KeyboardEvent.prototype.preventDefault = function() {
if (this.type !== 'keyup') {
return origPrevDef.apply(this, arguments);
}
throw new Error('Prevent default called on keyboard event.');
};
// Break on adding capturing listener:
var origAddEvLis = Node.prototype.addEventListener;
Node.prototype.addEventListener = function(event, handler, capturing) {
if (event === 'keyup' && capturing) {
debugger;
}
return origAddEvList.apply(this, arguments);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment