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([