unregister CM on closing showCodeMirrorPopup

This commit is contained in:
tophf 2017-12-09 18:23:18 +03:00
parent 9c1c15465e
commit 5f1f9c4d86
2 changed files with 7 additions and 2 deletions

View File

@ -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;
}

View File

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