There is a ton of unused, broken, or otherwise questionable logic in this module. This is a tracking task for the various related patches I'll be submitting shortly to thin it down a bit.
Mainly these three things:
Remove unused savedUnloadHandler logic
This hasn't worked or otherwise done anything since 2013 (ref T35566), when we switched the code from using window.onbeforeunload, to using window.addEventListener (via jQuery), but kept this "Firefox 3 bug fix" using the old method, and thus didn't do anything since then.
It seems plausible that the Firefox bug relating to the "beforeunload" event handler would happen via either registration mechanism. But, if that were the case, we would have presumably had a bug report by now about something having regressed.
More likely, the bug was either fixed at some point since Firefox 3, or perhaps it really was limited to the legacy window.onbeforeunload property.
Remove jQuery-event-namespace option
I have no idea why this exists. I suspect maybe the patch author in 2013 didn't know that event handlers can be removed by passingn the function reference, and perhaps the namespace was a way to be able to unregister just our handler (instead of also unregistering handlers from other unrelated features).
Defer or remove interface message processing
All major browsers have removed support for displaying a custom message upon tab-closing. As such, I suggest we remove the code for this instead of shipping, translating, parsing, and returning a string that is never displayed.
https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
Firefox | Edge | Safari | Chrome |
---|---|---|---|