Skip to content

Commit 5f5fce5

Browse files
author
Benjamin Pasero
committed
web - switch back to window.onbeforeunload as otherwise the page unload can no longer be prevented
1 parent cc845dc commit 5f5fce5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/vs/platform/lifecycle/browser/lifecycleService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { ILogService } from 'vs/platform/log/common/log';
88
import { AbstractLifecycleService } from 'vs/platform/lifecycle/common/lifecycleService';
99
import { localize } from 'vs/nls';
1010
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
11-
import { addDisposableListener, EventType } from 'vs/base/browser/dom';
1211

1312
export class BrowserLifecycleService extends AbstractLifecycleService {
1413

@@ -23,7 +22,9 @@ export class BrowserLifecycleService extends AbstractLifecycleService {
2322
}
2423

2524
private registerListeners(): void {
26-
addDisposableListener(window, EventType.BEFORE_UNLOAD, () => this.onBeforeUnload());
25+
// Note: we cannot change this to window.addEventListener('beforeUnload')
26+
// because it seems that mechanism does not allow for preventing the unload
27+
window.onbeforeunload = () => this.onBeforeUnload();
2728
}
2829

2930
private onBeforeUnload(): string | null {

0 commit comments

Comments
 (0)