fix first click on regexp tester

This commit is contained in:
tophf 2022-01-27 06:03:37 +03:00
parent 4c4a319b33
commit 8afab0eaeb

View File

@ -157,22 +157,16 @@ function createSection(originalSection, genId, si) {
} }
async function updateRegexpTester(toggle) { async function updateRegexpTester(toggle) {
const isLoaded = typeof regexpTester === 'object'; const isLoaded = typeof regexpTester === 'object' ||
if (toggle && !isLoaded) { toggle && await require(['/edit/regexp-tester']); /* global regexpTester */
await require(['/edit/regexp-tester']); /* global regexpTester */ if (toggle != null) {
}
if (toggle != null && isLoaded) {
regexpTester.toggle(toggle); regexpTester.toggle(toggle);
} }
const regexps = appliesTo.filter(a => a.type === 'regexp') const regexps = appliesTo.filter(a => a.type === 'regexp')
.map(a => a.value); .map(a => a.value);
if (regexps.length) { const hasRe = regexps.length > 0;
el.classList.add('has-regexp'); if (hasRe && isLoaded) regexpTester.update(regexps);
if (isLoaded) regexpTester.update(regexps); el.classList.toggle('has-regexp', hasRe);
} else {
el.classList.remove('has-regexp');
if (isLoaded) regexpTester.toggle(false);
}
} }
function updateTocEntry(origin) { function updateTocEntry(origin) {