From c963a1393283882bc3711f8600f70d2f508946a9 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 20 Jul 2017 12:16:36 +0300 Subject: [PATCH] code cosmetics Reorganize showRegExpTester()'s render stats code to better reflect the displayed structure/order of data --- edit/edit.js | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/edit/edit.js b/edit/edit.js index bbad11d0..f037bf89 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -1897,30 +1897,31 @@ function showRegExpTester(event, section = getSectionForChild(this)) { if (!data.length) { continue; } - // 2nd level: regexp text - const summary = $element({tag: 'summary', appendChild: label}); - const block = [summary]; - for (const {text, urls} of data) { - if (!urls) { - block.push(text, br.cloneNode()); - continue; - } - block.push($element({ - tag: 'details', - open: true, - appendChild: [ - $element({tag: 'summary', textContent: text}), - // 3rd level: tab urls - ...urls, - ], - })); - } - report.appendChild($element({ + const block = report.appendChild($element({ tag: 'details', open: true, dataset: {type}, - appendChild: block, + appendChild: $element({tag: 'summary', appendChild: label}), })); + // 2nd level: regexp text + for (const {text, urls} of data) { + if (urls) { + // type is partial or full + block.appendChild($element({ + tag: 'details', + open: true, + appendChild: [ + $element({tag: 'summary', textContent: text}), + // 3rd level: tab urls + ...urls, + ], + })); + } else { + // type is none or invalid + block.appendChild(document.createTextNode(text)); + block.appendChild(br.cloneNode()); + } + } } showHelp(t('styleRegexpTestTitle'), report);