From 576f73f3336e5f68aab2adad3ad79c7920f4ae8c Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 14 Oct 2018 03:03:35 +0800 Subject: [PATCH] Fix: always register listeners --- edit/edit.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/edit/edit.js b/edit/edit.js index 103159ea..6c125770 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -335,7 +335,7 @@ function onRuntimeMessage(request) { case 'styleDeleted': if (editor.getStyleId() === request.style.id) { document.removeEventListener('visibilitychange', beforeUnload); - window.onbeforeunload = null; + document.removeEventListener('beforeunload', beforeUnload); closeCurrentTab(); break; } @@ -364,11 +364,7 @@ function beforeUnload(e) { } if (editor && editor.isDirty()) { // neither confirm() nor custom messages work in modern browsers but just in case - if (e) { - e.returnValue = t('styleChangesNotSaved'); - } else { - return t('styleChangesNotSaved'); - } + e.returnValue = t('styleChangesNotSaved'); } }