豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit adac7c5

Browse files
authored
fix: repair broken markdown and extract snippets in a11y-debugging skill (#1096)
## Summary - Fix broken markdown fences in `skills/a11y-debugging/SKILL.md` — a stray quadruple-backtick on line 72 broke the numbered list continuation, and a mismatched fence on line 95 disrupted rendering - Extract verbose JS snippets (orphaned inputs, tap targets, color contrast, global checks) into `references/a11y-snippets.md`, keeping SKILL.md scannable and following the same `references/` pattern used by `debug-optimize-lcp` ## Test plan - [x] Verify SKILL.md renders correctly in GitHub markdown preview (no broken fences or orphaned code blocks) - [x] Verify `references/a11y-snippets.md` renders correctly and all 4 snippets are present - [x] Confirm the relative links from SKILL.md to `references/a11y-snippets.md` resolve correctly on GitHub
1 parent cb0079e commit adac7c5

File tree

2 files changed

+97
-84
lines changed

2 files changed

+97
-84
lines changed

skills/a11y-debugging/SKILL.md

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,7 @@ The accessibility tree exposes the heading hierarchy and semantic landmarks.
5151

5252
1. Locate buttons, inputs, and images in the `take_snapshot` output.
5353
2. Ensure interactive elements have an accessible name (e.g., a button should not just say `""` if it only contains an icon).
54-
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`:
55-
```js
56-
() =>
57-
Array.from(document.querySelectorAll('input, select, textarea'))
58-
.filter(i => {
59-
const hasId = i.id && document.querySelector(`label[for="${i.id}"]`);
60-
const hasAria =
61-
i.getAttribute('aria-label') || i.getAttribute('aria-labelledby');
62-
return !hasId && !hasAria && !i.closest('label');
63-
})
64-
.map(i => ({
65-
tag: i.tagName,
66-
id: i.id,
67-
name: i.name,
68-
placeholder: i.placeholder,
69-
}));
70-
```
71-
72-
````
73-
54+
3. **Orphaned Inputs**: Verify that all form inputs have associated labels. Use `evaluate_script` with the **"Find Orphaned Form Inputs" snippet** found in [references/a11y-snippets.md](references/a11y-snippets.md).
7455
4. Check images for `alt` text.
7556

7657
### 5. Focus & Keyboard Navigation
@@ -84,15 +65,7 @@ Testing "keyboard traps" and proper focus management without visual feedback rel
8465

8566
### 6. Tap Targets and Visuals
8667

87-
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`:
88-
89-
```js
90-
// Usage in console: copy, paste, and call with element: fn(element)
91-
el => {
92-
const rect = el.getBoundingClientRect();
93-
return {width: rect.width, height: rect.height};
94-
};
95-
````
68+
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` with the **"Measure Tap Target Size" snippet** found in [references/a11y-snippets.md](references/a11y-snippets.md).
9669
9770
_Pass the element's `uid` from the snapshot as an argument to `evaluate_script`._
9871

@@ -103,66 +76,14 @@ To verify color contrast ratios, start by checking for native accessibility issu
10376
1. Call `list_console_messages` with `types: ["issue"]`.
10477
2. Look for "Low Contrast" issues in the output.
10578

106-
If native audits do not report issues (which may happen in some headless environments) or if you need to check a specific element manually, you can use the following script as a fallback approximation.
107-
108-
**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`.
109-
110-
```js
111-
el => {
112-
function getRGB(colorStr) {
113-
const match = colorStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
114-
return match
115-
? [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])]
116-
: [255, 255, 255];
117-
}
118-
function luminance(r, g, b) {
119-
const a = [r, g, b].map(function (v) {
120-
v /= 255;
121-
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
122-
});
123-
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
124-
}
125-
126-
const style = window.getComputedStyle(el);
127-
const fg = getRGB(style.color);
128-
let bg = getRGB(style.backgroundColor);
129-
130-
// Basic contrast calculation (Note: Doesn't account for transparency over background images)
131-
const l1 = luminance(fg[0], fg[1], fg[2]);
132-
const l2 = luminance(bg[0], bg[1], bg[2]);
133-
const ratio = (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
134-
135-
return {
136-
color: style.color,
137-
bg: style.backgroundColor,
138-
contrastRatio: ratio.toFixed(2),
139-
};
140-
};
141-
```
142-
143-
_Pass the element's `uid` to test the contrast against WCAG AA (4.5:1 for normal text, 3:1 for large text)._
79+
If native audits do not report issues (which may happen in some headless environments) or if you need to check a specific element manually, use `evaluate_script` with the **"Check Color Contrast" snippet** found in [references/a11y-snippets.md](references/a11y-snippets.md).
14480

14581
### 8. Global Page Checks
14682

147-
Verify document-level accessibility settings often missed in component testing:
148-
149-
```js
150-
() => ({
151-
lang:
152-
document.documentElement.lang ||
153-
'MISSING - Screen readers need this for pronunciation',
154-
title: document.title || 'MISSING - Required for context',
155-
viewport:
156-
document.querySelector('meta[name="viewport"]')?.content ||
157-
'MISSING - Check for user-scalable=no (bad practice)',
158-
reducedMotion: window.matchMedia('(prefers-reduced-motion: reduce)').matches
159-
? 'Enabled'
160-
: 'Disabled',
161-
});
162-
```
83+
Verify document-level accessibility settings often missed in component testing using the **"Global Page Checks" snippet** found in [references/a11y-snippets.md](references/a11y-snippets.md).
16384

16485
## Troubleshooting
16586

16687
If standard a11y queries fail or the `evaluate_script` snippets return unexpected results:
16788

168-
- **Visual Inspection**: If automated scripts cannot determine contrast (e.g., text over gradient images or complex backgrounds), use `take_screenshot` to capture the element. While models cannot measure exact contrast ratios from images, they can visually assess legibility and identifying obvious issues.
89+
- **Visual Inspection**: If automated scripts cannot determine contrast (e.g., text over gradient images or complex backgrounds), use `take_screenshot` to capture the element. While models cannot measure exact contrast ratios from images, they can visually assess legibility and identify obvious issues.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Accessibility Debugging Snippets
2+
3+
Use these JavaScript snippets with the `evaluate_script` tool.
4+
5+
## 1. Find Orphaned Form Inputs
6+
7+
Finds form inputs that lack an associated label (no `label[for]`, `aria-label`, `aria-labelledby`, or wrapping `<label>`).
8+
9+
```js
10+
() =>
11+
Array.from(document.querySelectorAll('input, select, textarea'))
12+
.filter(i => {
13+
const hasId = i.id && document.querySelector(`label[for="${i.id}"]`);
14+
const hasAria =
15+
i.getAttribute('aria-label') || i.getAttribute('aria-labelledby');
16+
return !hasId && !hasAria && !i.closest('label');
17+
})
18+
.map(i => ({
19+
tag: i.tagName,
20+
id: i.id,
21+
name: i.name,
22+
placeholder: i.placeholder,
23+
}));
24+
```
25+
26+
## 2. Measure Tap Target Size
27+
28+
Returns the bounding box dimensions of an element. Pass the element's `uid` from the snapshot as an argument to `evaluate_script`.
29+
30+
```js
31+
el => {
32+
const rect = el.getBoundingClientRect();
33+
return {width: rect.width, height: rect.height};
34+
};
35+
```
36+
37+
## 3. Check Color Contrast
38+
39+
Approximates the contrast ratio between an element's text color and background color. Pass the element's `uid` to test against WCAG AA (4.5:1 for normal text, 3:1 for large text).
40+
41+
**Note**: This uses a simplified algorithm and may not account for transparency, gradients, or background images. For production-grade auditing, consider injecting `axe-core`.
42+
43+
```js
44+
el => {
45+
function getRGB(colorStr) {
46+
const match = colorStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
47+
return match
48+
? [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])]
49+
: [255, 255, 255];
50+
}
51+
function luminance(r, g, b) {
52+
const a = [r, g, b].map(function (v) {
53+
v /= 255;
54+
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
55+
});
56+
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
57+
}
58+
59+
const style = window.getComputedStyle(el);
60+
const fg = getRGB(style.color);
61+
let bg = getRGB(style.backgroundColor);
62+
63+
const l1 = luminance(fg[0], fg[1], fg[2]);
64+
const l2 = luminance(bg[0], bg[1], bg[2]);
65+
const ratio = (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
66+
67+
return {
68+
color: style.color,
69+
bg: style.backgroundColor,
70+
contrastRatio: ratio.toFixed(2),
71+
};
72+
};
73+
```
74+
75+
## 4. Global Page Checks
76+
77+
Checks document-level accessibility settings often missed in component testing.
78+
79+
```js
80+
() => ({
81+
lang:
82+
document.documentElement.lang ||
83+
'MISSING - Screen readers need this for pronunciation',
84+
title: document.title || 'MISSING - Required for context',
85+
viewport:
86+
document.querySelector('meta[name="viewport"]')?.content ||
87+
'MISSING - Check for user-scalable=no (bad practice)',
88+
reducedMotion: window.matchMedia('(prefers-reduced-motion: reduce)').matches
89+
? 'Enabled'
90+
: 'Disabled',
91+
});
92+
```

0 commit comments

Comments
 (0)