From 8afab0eaeb2f643701295c8e18ff16a4b65ae4c6 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 27 Jan 2022 06:03:37 +0300 Subject: [PATCH] fix first click on regexp tester --- edit/sections-editor-section.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/edit/sections-editor-section.js b/edit/sections-editor-section.js index 9f1e50b9..a8cee631 100644 --- a/edit/sections-editor-section.js +++ b/edit/sections-editor-section.js @@ -157,22 +157,16 @@ function createSection(originalSection, genId, si) { } async function updateRegexpTester(toggle) { - const isLoaded = typeof regexpTester === 'object'; - if (toggle && !isLoaded) { - await require(['/edit/regexp-tester']); /* global regexpTester */ - } - if (toggle != null && isLoaded) { + const isLoaded = typeof regexpTester === 'object' || + toggle && await require(['/edit/regexp-tester']); /* global regexpTester */ + if (toggle != null) { regexpTester.toggle(toggle); } const regexps = appliesTo.filter(a => a.type === 'regexp') .map(a => a.value); - if (regexps.length) { - el.classList.add('has-regexp'); - if (isLoaded) regexpTester.update(regexps); - } else { - el.classList.remove('has-regexp'); - if (isLoaded) regexpTester.toggle(false); - } + const hasRe = regexps.length > 0; + if (hasRe && isLoaded) regexpTester.update(regexps); + el.classList.toggle('has-regexp', hasRe); } function updateTocEntry(origin) {