I've been experimenting with events in my script, but I'm struggling to understand the functionality of event.preventDefault()/event.defaultPrevented:
var e = new Event('test');
e.defaultPrevented;
> false
e.preventDefault();
e.defaultPrevented;
> false
How can I set e.defaultPrevented
to true
?
It's behaving consistently across Chrome, Firefox, and Edge, so I must be missing something.
Thank you :)
UPDATE : The problem was that I didn't define the Event with:
var e = new Event('test', {cancelable: true});