(hash)
| 51 | |
| 52 | export function getUnloadSentry(onConfirm, onCancel) { |
| 53 | async function confirmPopState(hash) { |
| 54 | if (await showConfirmation(i18n('confirmNotSaved'))) { |
| 55 | // popstate cannot be prevented so we pin current `route` and display a confirmation |
| 56 | setRoute(hash, false, true); |
| 57 | onConfirm?.(); |
| 58 | } else { |
| 59 | onCancel?.(); |
| 60 | } |
| 61 | } |
| 62 | function toggle(state) { |
| 63 | const onOff = `${state ? 'add' : 'remove'}EventListener`; |
| 64 | global[onOff]('beforeunload', onUnload); |
nothing calls this directly
no test coverage detected