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:
Claude
2026-07-08 15:19:53 +00:00
parent 22d3d8c1ff
commit 6e3f334e10
+14 -9
View File
@@ -241,16 +241,13 @@
}); });
} }
// Reveal any collapsed nested section (from render_nested_section) so the function isNodeHidden(node) {
// target field is actually visible before we scroll to it. return node.classList.contains('hidden') ||
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') || (node.style && node.style.display === 'none') ||
(window.getComputedStyle(node).display === 'none'); window.getComputedStyle(node).display === 'none';
if (hidden) { }
function revealNode(node) {
// toggleSection handles the class, inline display, and chevron. // toggleSection handles the class, inline display, and chevron.
if (node.id && typeof window.toggleSection === 'function') { if (node.id && typeof window.toggleSection === 'function') {
window.toggleSection(node.id); window.toggleSection(node.id);
@@ -259,6 +256,14 @@
node.style.display = 'block'; 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') && isNodeHidden(node)) {
revealNode(node);
} }
node = node.parentElement; node = node.parentElement;
} }