I am working on a Firefox extension and continue to see the following warning:
Using getPreventDefault () is not recommended. Use defaultPrevented instead.
However, for what I'm trying to do, it defaultPreventeddoesn't seem to work while it getPreventDefault()works. For a simplified snippet of code, here is what I inserted into the notepad of the Firefox browser when working in context Browser:
window.addEventListener('fooEvent', function (event) {
console.log('fooEvent has fired');
event.preventDefault();
}, true, true);
Then in the browser console (the one that I get when I press Shift + Ctrl + k) I run the following code:
e = document.createEvent('Event');
e.initEvent('fooEvent', true, true);
document.dispatchEvent(e);
console.log('after dispatch', e.defaultPrevented, e.getPreventDefault());
fooEvent has fired fooEvent has fired Javascript, , . after dispatch false true , defaultPrevented - false, getPreventDefault() true. Firefox - !
API, , Firefox . ( API, , , , , , , .) ?