-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { AccessibilityError } from "../scanner"; | ||
import { querySelector, querySelectorAll } from "../utils"; | ||
|
||
const id = "ye5d6e"; | ||
const url = `https://act-rules.github.io/rules/${id}`; | ||
const text = "Document has an instrument to move focus to non-repeated content"; | ||
|
||
// TODO: The tests don't work yet because the document doesn't load correctly in the test harness. | ||
export default function (el: Document | Element): AccessibilityError[] { | ||
const errors = []; | ||
const document = el instanceof Document ? el : el.ownerDocument; | ||
const links = querySelectorAll("a[href^='#']", document); | ||
|
||
let hasInstrument = false; | ||
|
||
for (const link of links) { | ||
const target = querySelector(link.getAttribute("href")!, document); | ||
if (target?.parentElement?.isSameNode(document.body)) hasInstrument = true; | ||
} | ||
if (hasInstrument) { | ||
errors.push({ | ||
element: document.body, | ||
text, | ||
url, | ||
}); | ||
} | ||
return errors; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters