fix: reject native-hidden semantic evidence
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user