Fix for hidden elements

This commit is contained in:
Josh at WLTechBlog
2025-12-09 11:48:45 -07:00
parent fb7e07aae9
commit 0c8622294b

View File

@@ -9226,6 +9226,21 @@ func (d *Daemon) checkContrast(tabID string, selector string, timeout int) (*Con
// Get computed styles // Get computed styles
const style = window.getComputedStyle(element); const style = window.getComputedStyle(element);
// Skip elements that are not visible (WCAG only applies to visible content)
// Check for display: none, visibility: hidden, opacity: 0
if (style.display === 'none' ||
style.visibility === 'hidden' ||
parseFloat(style.opacity) === 0) {
return;
}
// Also skip if element has no dimensions (effectively hidden)
const rect = element.getBoundingClientRect();
if (rect.width === 0 || rect.height === 0) {
return;
}
const fgColor = style.color; const fgColor = style.color;
const fontSize = style.fontSize; const fontSize = style.fontSize;
const fontWeight = style.fontWeight; const fontWeight = style.fontWeight;