From eddf8764dd0f6396af41e9a7fba320adc84d96c7 Mon Sep 17 00:00:00 2001 From: Duarte Henriques Date: Tue, 11 Sep 2018 11:59:06 +0100 Subject: [PATCH] Only change onbeforeunload when that option is set --- src/editor/model/Editor.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 2c66604c0..9f5d0f778 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -137,10 +137,8 @@ module.exports = Backbone.Model.extend({ const stm = this.get('StorageManager'); const changes = this.get('changesCount'); - if (this.config.noticeOnUnload && changes) { - window.onbeforeunload = e => 1; - } else { - window.onbeforeunload = null; + if (this.config.noticeOnUnload) { + window.onbeforeunload = changes ? e => 1 : null; } if (stm.isAutosave() && changes >= stm.getStepsBeforeSave()) {