fix: reject native-hidden semantic evidence

This commit is contained in:
2026-09-02 02:54:24 +03:00
parent c16c4c57da
commit 3638a0beef
2 changed files with 62 additions and 3 deletions

View File

@@ -145,13 +145,19 @@ const excludedSemanticContainers = new Set(['SCRIPT', 'STYLE', 'TEMPLATE', 'NOSC
const isVisibleSemanticNode = (node, appRoot) => {
if (!node.isConnected || !appRoot.contains(node)) return false;
let element = node.nodeType === 1 ? node : node.parentElement;
const originElement = node.nodeType === 1 ? node : node.parentElement;
let element = originElement;
while (element !== null) {
if (excludedSemanticContainers.has(element.tagName) || element.hasAttribute('hidden') ||
element.hasAttribute('inert') || element.getAttribute('aria-hidden') === 'true' ||
element.hasAttribute('inert') || element.getAttribute('aria-hidden')?.toLowerCase() === 'true' ||
(element.tagName === 'DIALOG' && !element.hasAttribute('open')) ||
element.style?.display === 'none' || element.style?.visibility === 'hidden') {
return false;
}
if (element.tagName === 'DETAILS' && !element.hasAttribute('open') && originElement !== element) {
const summary = [...element.children].find((child) => child.tagName === 'SUMMARY');
if (summary === undefined || (originElement !== summary && !summary.contains(originElement))) return false;
}
if (element === appRoot) return true;
element = element.parentElement;
}