mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-08-02 17:28:05 +00:00
Reduce complexity of revealAncestors in settings search
Extract isNodeHidden() and revealNode() helpers so revealAncestors drops below the cyclomatic-complexity threshold. No behavior change; verified with the headless-Chromium test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014gZxznuxw8L92FUMBN3Nqz
This commit is contained in:
@@ -241,24 +241,29 @@
|
||||
});
|
||||
}
|
||||
|
||||
function isNodeHidden(node) {
|
||||
return node.classList.contains('hidden') ||
|
||||
(node.style && node.style.display === 'none') ||
|
||||
window.getComputedStyle(node).display === 'none';
|
||||
}
|
||||
|
||||
function revealNode(node) {
|
||||
// toggleSection handles the class, inline display, and chevron.
|
||||
if (node.id && typeof window.toggleSection === 'function') {
|
||||
window.toggleSection(node.id);
|
||||
} else {
|
||||
node.classList.remove('hidden');
|
||||
node.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
// Reveal any collapsed nested section (from render_nested_section) so the
|
||||
// target field is actually visible before we scroll to it.
|
||||
function revealAncestors(el) {
|
||||
var node = el.parentElement;
|
||||
while (node && node !== document.body) {
|
||||
if (node.classList && node.classList.contains('nested-content')) {
|
||||
var hidden = node.classList.contains('hidden') ||
|
||||
(node.style && node.style.display === 'none') ||
|
||||
(window.getComputedStyle(node).display === 'none');
|
||||
if (hidden) {
|
||||
// toggleSection handles the class, inline display, and chevron.
|
||||
if (node.id && typeof window.toggleSection === 'function') {
|
||||
window.toggleSection(node.id);
|
||||
} else {
|
||||
node.classList.remove('hidden');
|
||||
node.style.display = 'block';
|
||||
}
|
||||
}
|
||||
if (node.classList && node.classList.contains('nested-content') && isNodeHidden(node)) {
|
||||
revealNode(node);
|
||||
}
|
||||
node = node.parentElement;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user