Files
GNX-mailEnterprise/frontend/node_modules/unload/dist/lib/browser.js
Iliyan Angelov c67067a2a4 Mail
2025-09-14 23:24:25 +03:00

43 lines
1.0 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
/* global WorkerGlobalScope */
function add(fn) {
if (typeof WorkerGlobalScope === 'function' && self instanceof WorkerGlobalScope) {// this is run inside of a webworker
} else {
/**
* if we are on react-native, there is no window.addEventListener
* @link https://github.com/pubkey/unload/issues/6
*/
if (typeof window.addEventListener !== 'function') return;
/**
* for normal browser-windows, we use the beforeunload-event
*/
window.addEventListener('beforeunload', function () {
fn();
}, true);
/**
* for iframes, we have to use the unload-event
* @link https://stackoverflow.com/q/47533670/3443137
*/
window.addEventListener('unload', function () {
fn();
}, true);
}
/**
* TODO add fallback for safari-mobile
* @link https://stackoverflow.com/a/26193516/3443137
*/
}
var _default = {
add: add
};
exports["default"] = _default;