Skip to content

Commit 5cedcaa

Browse files
authored
refactor: simplify JavaScript code examples, update code block language, and refine descriptions in a11y debugging skill documentation. (#1009)
1 parent 33446d4 commit 5cedcaa

File tree

1 file changed

+21
-35
lines changed

1 file changed

+21
-35
lines changed

skills/a11y-debugging/SKILL.md

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Uses Chrome DevTools MCP for accessibility (a11y) debugging and aud
77

88
**Accessibility Tree vs DOM**: Visually hiding an element (e.g., `CSS opacity: 0`) behaves differently for screen readers than `display: none` or `aria-hidden="true"`. The `take_snapshot` tool returns the accessibility tree of the page, which represents what assistive technologies "see", making it the most reliable source of truth for semantic structure.
99

10-
**Reading web.dev documentation**: If you need to research specific accessibility guidelines (like `https://web.dev/articles/accessible-tap-targets`), you can append `.md.txt` to the URL (e.g., `https://web.dev/articles/accessible-tap-targets.md.txt`) to fetch the clean, raw markdown version. This is much easier to read using the `read_url_content` tool!
10+
**Reading web.dev documentation**: If you need to research specific accessibility guidelines (like `https://web.dev/articles/accessible-tap-targets`), you can append `.md.txt` to the URL (e.g., `https://web.dev/articles/accessible-tap-targets.md.txt`) to fetch the clean, raw markdown version. This is much easier to read!
1111

1212
## Workflow Patterns
1313

@@ -34,26 +34,21 @@ The accessibility tree exposes the heading hierarchy and semantic landmarks.
3434
1. Locate buttons, inputs, and images in the `take_snapshot` output.
3535
2. Ensure interactive elements have an accessible name (e.g., a button should not just say `""` if it only contains an icon).
3636
3. **Orphaned Inputs**: Verify that all form inputs have associated labels. Use `evaluate_script` to check for inputs missing `id` (for `label[for]`) or `aria-label`:
37-
```javascript
38-
() => {
39-
const inputs = Array.from(
40-
document.querySelectorAll('input, select, textarea'),
41-
);
42-
return inputs
37+
```js
38+
() =>
39+
Array.from(document.querySelectorAll('input, select, textarea'))
4340
.filter(i => {
4441
const hasId = i.id && document.querySelector(`label[for="${i.id}"]`);
4542
const hasAria =
4643
i.getAttribute('aria-label') || i.getAttribute('aria-labelledby');
47-
const hasImplicitLabel = i.closest('label');
48-
return !hasId && !hasAria && !hasImplicitLabel;
44+
return !hasId && !hasAria && !i.closest('label');
4945
})
5046
.map(i => ({
5147
tag: i.tagName,
5248
id: i.id,
5349
name: i.name,
5450
placeholder: i.placeholder,
5551
}));
56-
};
5752
```
5853

5954
````
@@ -73,15 +68,15 @@ Testing "keyboard traps" and proper focus management without visual feedback rel
7368

7469
According to web.dev, tap targets should be at least 48x48 pixels with sufficient spacing. Since the accessibility tree doesn't show sizes, use `evaluate_script`:
7570
76-
```javascript
71+
```js
7772
// Usage in console: copy, paste, and call with element: fn(element)
7873
el => {
7974
const rect = el.getBoundingClientRect();
8075
return {width: rect.width, height: rect.height};
8176
};
8277
````
8378
84-
_Pass the element's `uid` from the snapshot as an argument to the tool._
79+
_Pass the element's `uid` from the snapshot as an argument to `evaluate_script`._
8580

8681
### 6. Color Contrast
8782

@@ -94,7 +89,7 @@ If native audits do not report issues (which may happen in some headless environ
9489

9590
**Note**: This script uses a simplified algorithm and may not account for transparency, gradients, or background images. For production-grade auditing, consider injecting `axe-core`.
9691

97-
```javascript
92+
```js
9893
el => {
9994
function getRGB(colorStr) {
10095
const match = colorStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
@@ -133,28 +128,19 @@ _Pass the element's `uid` to test the contrast against WCAG AA (4.5:1 for normal
133128
134129
Verify document-level accessibility settings often missed in component testing:
135130
136-
```javascript
137-
(() => {
138-
const f = () => {
139-
return {
140-
lang:
141-
document.documentElement.lang ||
142-
'MISSING - Screen readers need this for pronunciation',
143-
title: document.title || 'MISSING - Required for context',
144-
viewport:
145-
document.querySelector('meta[name="viewport"]')?.content ||
146-
'MISSING - Check for user-scalable=no (bad practice)',
147-
reducedMotion: window.matchMedia('(prefers-reduced-motion: reduce)')
148-
.matches
149-
? 'Enabled'
150-
: 'Disabled',
151-
};
152-
};
153-
try {
154-
console.log(f());
155-
} catch (e) {} // Log for manual console usage
156-
return f;
157-
})();
131+
```js
132+
() => ({
133+
lang:
134+
document.documentElement.lang ||
135+
'MISSING - Screen readers need this for pronunciation',
136+
title: document.title || 'MISSING - Required for context',
137+
viewport:
138+
document.querySelector('meta[name="viewport"]')?.content ||
139+
'MISSING - Check for user-scalable=no (bad practice)',
140+
reducedMotion: window.matchMedia('(prefers-reduced-motion: reduce)').matches
141+
? 'Enabled'
142+
: 'Disabled',
143+
});
158144
```
159145
160146
## Troubleshooting

0 commit comments

Comments
 (0)