Find preventDefault or stopPropagation JavaScript
Event.prototype.preventDefault = () => {
debugger;
};
// @NOTE `stopPropagation` or `stopImmediatePropagation` could also be
// preventing events
// Event.prototype.stopPropagation = () => {
// debugger;
// };
This is a real life saver – especially for large confusing legacy projects with lots of event logic. You can use this to track down an unwanted preventDefault
and/or stopPropagation
. I needed this recently to see which of many calls to preventDefault
was preventing my touch events from working in a certain area.
I usually pop this into the console and step through things. If you’ve never seen debugger
before read about it here…