From 5f1f9c4d86816744d989ffea5ceab4a6441e0451 Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 9 Dec 2017 18:23:18 +0300 Subject: [PATCH] unregister CM on closing showCodeMirrorPopup --- edit/edit.js | 6 +++++- edit/lint.js | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/edit/edit.js b/edit/edit.js index 873841a3..9067eaab 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -562,7 +562,7 @@ function showCodeMirrorPopup(title, html, options) { const popup = showHelp(title, html); popup.classList.add('big'); - const cm = popup.codebox = CodeMirror($('.contents', popup), Object.assign({ + let cm = popup.codebox = CodeMirror($('.contents', popup), Object.assign({ mode: 'css', lineNumbers: true, lineWrapping: true, @@ -577,6 +577,10 @@ function showCodeMirrorPopup(title, html, options) { cm.focus(); cm.on('focus', () => cm.rerouteHotkeys(false)); cm.on('blur', () => cm.rerouteHotkeys(true)); + window.addEventListener('closeHelp', function _() { + window.removeEventListener('closeHelp', _); + cm = popup.codebox = null; + }); return popup; } diff --git a/edit/lint.js b/edit/lint.js index f4fd8e64..f8792862 100644 --- a/edit/lint.js +++ b/edit/lint.js @@ -419,7 +419,7 @@ function setupLinterPopup(config) { }); $('.contents', popup).appendChild(makeFooter()); - const cm = popup.codebox; + let cm = popup.codebox; cm.focus(); cm.setValue(config); cm.clearHistory(); @@ -431,6 +431,7 @@ function setupLinterPopup(config) { window.addEventListener('closeHelp', function _() { window.removeEventListener('closeHelp', _); cm.rerouteHotkeys(true); + cm = null; }); loadScript([