EDIT: Not necessary to adopt this approach because there were no timing problems after all...
Question: Are the following two approaches correct equivalents?
The current native approach(suspected to be buggy):
_trigger = (t, e) => {
let ev = document.createEvent('HTMLEvents');
ev.initEvent("pronto." + t, true, false);
ev.data = e ? e : RQ("e");
window.dispatchEvent(ev);
document.dispatchEvent(ev);
}
At first sight, I would suspect, that at the very least the second dispatchEvent() in the above approach is superfluous and maybe even results in double firing?
The old jQuery approach(definitely works):
function _trigger(t, e){ //trigger a custom event
e = e ? e : RQ("e"); //if e not passed, then use existing internal event data
jQuery(window).trigger("pronto." + t, e); //always prepend "pronto." and pass the bespoke data in the second variable
}
EDIT: Not necessary to adopt this approach because there were no timing problems after all...
Question: Are the following two approaches correct equivalents?
The current native approach(suspected to be buggy):
At first sight, I would suspect, that at the very least the second
dispatchEvent()
in the above approach is superfluous and maybe even results in double firing?The old jQuery approach(definitely works):
That's to say, that the following should work on everything except IE ->
What do you think of the latter approach?