simplify theme preloader

This commit is contained in:
tophf 2017-12-05 03:54:43 +03:00
parent a6f63d096e
commit 1e1ff73612
2 changed files with 6 additions and 9 deletions

View File

@ -72,7 +72,6 @@
<script src="edit/codemirror-default.js"></script>
<link rel="stylesheet" href="/edit/codemirror-default.css">
<link id="cm-theme" rel="stylesheet">
<template data-id="appliesTo">
<li>

View File

@ -92,14 +92,12 @@ function preinit() {
});
// preload the theme so that CodeMirror can calculate its metrics in DOMContentLoaded->setupLivePrefs()
new MutationObserver((mutations, observer) => {
const themeElement = $('#cm-theme');
if (themeElement) {
themeElement.href = prefs.get('editor.theme') === 'default' ? ''
: 'vendor/codemirror/theme/' + prefs.get('editor.theme') + '.css';
observer.disconnect();
}
}).observe(document, {subtree: true, childList: true});
document.head.appendChild(
$create('link#cm-theme', {
rel: 'stylesheet',
href: prefs.get('editor.theme') === 'default' ? '' :
'vendor/codemirror/theme/' + prefs.get('editor.theme') + '.css'
}));
if (chrome.windows) {
queryTabs({currentWindow: true}).then(tabs => {