You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fe9e910
Browse filesBrowse the repository at this point in the historyBrowse files
Find and check forms rendered inside an open shadow root
The last real, previously-documented-as-out-of-scope gap: a form built
with web components (a genuinely common pattern in modern government
design systems) renders its <form> and fields inside an open shadow
root, which plain document.querySelectorAll/querySelector can never
see into — it only ever searches light-DOM descendants. Every check
reported "No <form> element found", indistinguishable from the page
genuinely having no form at all.
Added a deep-query JS helper (DEEP_QUERY_JS) that recursively walks
both light-DOM children and open shadowRoot children, and applied it
everywhere a check queries from `document` or the resolved target form:
TARGET_FORM_JS's own form discovery and candidate ranking,
fill_form_fields, visible_buttons_js, check_mobile_usability's
tap-target scan, check_validation_errors' required/invalid lookups,
check_required_documents' and check_autofill_hints' file-input/label
lookups, and check_input_persistence's field lookup. check_accessibility
needed no change — axe-core already pierces shadow DOM natively.
Found a second, independent bug while verifying the fix end-to-end
against a real shadow-DOM fixture: TARGET_FORM_JS caches the picked
form on `window` and, on every later call, re-checks it's still on the
page via `document.contains(...)` before reusing it — but
`document.contains()` is defined in terms of ordinary (non-shadow-
including) descendants, so it's false for a shadow-rooted form even
while the form is very much still there. This silently broke every
check after the very first `page.evaluate()` call on such a page (the
form would resolve once, then "vanish" on every subsequent lookup).
Verified this empirically against the real fixture (not just reasoned
about) before fixing it: confirmed `document.contains()` returns false
while the shadow-rooted form's own `isConnected` correctly returns
true, then switched the cache-reuse check to `isConnected`, which is
shadow-aware by spec.
Both fixes were verified independently by reverting each one in turn
(via `git stash`, and via a one-line edit) and confirming the same
fixture reproduces the exact predicted failure each time, before
restoring.
Updated README's "known limitations" section: narrowed from "Shadow
DOM or iframe content is invisible" to the two limits that are actually
permanent (closed shadow roots, cross-origin iframes — real platform
boundaries, not formwatch gaps) now that open shadow roots work.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0 commit comments