Skip to content

Commit

Permalink
added support for caching and reusing a site's onbeforeunload callback
Browse files Browse the repository at this point in the history
thanks, @bromagosa !
  • Loading branch information
jmoenig committed Feb 12, 2024
1 parent 1ffb82a commit 79167db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion morphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@

/*jshint esversion: 11, bitwise: false*/

var morphicVersion = '2024-January-22';
var morphicVersion = '2024-February-12';
var modules = {}; // keep track of additional loaded modules
var useBlurredShadows = true;

Expand Down Expand Up @@ -12469,7 +12469,11 @@ WorldMorph.prototype.initEventListeners = function () {
false
);

window.cachedOnbeforeunload = window.onbeforeunload;
window.onbeforeunload = (evt) => {
if (window.cachedOnbeforeunload) {
window.cachedOnbeforeunload.call(null, evt);
}
var e = evt || window.event,
msg = "Are you sure you want to leave?";
// For IE and Firefox
Expand Down

0 comments on commit 79167db

Please sign in to comment.