diff --git a/scripts/verify-artifacts.mjs b/scripts/verify-artifacts.mjs index c7d7659..535801c 100644 --- a/scripts/verify-artifacts.mjs +++ b/scripts/verify-artifacts.mjs @@ -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; } diff --git a/tests/integration/verify-artifacts.test.ts b/tests/integration/verify-artifacts.test.ts index ef5495d..f301b29 100644 --- a/tests/integration/verify-artifacts.test.ts +++ b/tests/integration/verify-artifacts.test.ts @@ -36,6 +36,14 @@ const clientJavaScript = 'export {};\n'; const clientStylesheet = 'body { margin: 0; }\n'; const sha256 = (value: string): string => createHash('sha256').update(value).digest('hex'); +const wrapAppContents = (html: string, opening: string, closing: string): string => { + const appOpening = '