Alert
-
So recently I was fixing some jquery spaghetti (the bosses didn't allow refactoring, because 'We already have so much code, why waste it?' or something; fortunately they changed their mind since). I decided to display a native alert when some rare error occured (instead of failing silently). Shit, it doesn't work, I must have broken something somewhere... Then I found this gem, in a file included from somewhere 7 directories away:
window.alert = function() {};
This line appeared in a commit with an optimistic name "last fixes", in January 2017. The project is still under active development, with a completely new team and after total rewrite of about 60% of functionality.
-
@sebastian-galczynski said in Alert:
last fixes
"it's time to submit it"
"submit what?"
"the last commit you'll ever write..."
-
window.alert = (function() { var iframe = document.createElement('iframe'); iframe.style.display = 'none'; document.body.appendChild(iframe); return iframe.contentWindow.alert; })();
-
@anotherusername This still shows a popup. But I found something interesting:
var frame1 = document.getElementById('frame1'); frame1.contentWindow.alert('dupa1'); var frame2 = document.getElementById('frame2'); frame2.contentWindow.alert('dupa2');
If you do this in Firefox, you only see one alert ('dupa2'). But if you delay it with a timeout like this:
frame1.contentWindow.setTimeout(()=>{frame1.contentWindow.alert('dupa1');}, 1000); frame2.contentWindow.setTimeout(()=>{frame2.contentWindow.alert('dupa2');}, 2000);
It behaves as expected.
Should I report this on their bugzilla?
-
@sebastian-galczynski I honestly have no idea. I was running into a similar issue when I tried creating the
iframe
at the point when the alert was needed. The alert either didn't appear at all, or it flashed on the screen for an instant before disappearing.
-
@sebastian-galczynski Welcome back!
-
@Tsaukpaetra You know the difference between me and you? I make this commit look good.
-
@sebastian-galczynski said in Alert:
an optimistic name "last fixes"
This is the funniest thing I've read all week.
-