aria-required-parent
它能做什么
这项技能检查具有某些 ARIA 角色的元素是否位于其所需的父角色之内。适合构建菜单、标签页、列表或其他自定义小组件的开发者。
适用场景
- ✓当你用自定义元素构建菜单、标签页组或列表时。
- ✓当屏幕阅读器没有把各项目归为一组时。
- ✓当你审查使用 listitem、tab 或 menuitem 角色的组件时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/aria-required-parent/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我的菜单项是否位于 menu 元素之内,以便屏幕阅读器能把它们作为一组来读取。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会找出需要父级的项目,并把它们包裹在正确的容器角色中,或把它们移动到标记中的正确位置。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Ensure ARIA roles are contained by required parent roles
If an ARIA child role (like a menu item) is not contained within its required parent role (like a menu), screen readers may fail to announce the item as part of a group, breaking navigation.
Quick Reference
- Certain roles (like
listitem) must be owned by specific parent roles (likelist) - Ensure children elements are not orphaned from their semantic containers
- Maintain valid ARIA hierarchies for menu items, tabs, and list items
Check
Verify that elements with roles like listitem, tab, or menuitem are correctly nested within their required parent roles.
Fix
Wrap elements with roles that require a specific parent in the appropriate container role (e.g., wrap role="listitem" in role="list").
Explain
Explain why certain ARIA roles must be nested within specific parent containers to maintain semantic meaning and group navigation.
Code Review
Review the rendered markup and interactive states that affect Ensure ARIA roles are contained by required parent roles. Flag exact elements, roles, labels, focus behavior, or keyboard interactions that violate the rule, and note how to verify the fix with browser accessibility tooling or assistive tech.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/accessibility/aria-required-parent
常见问题
菜单项没有 menu 父级时会怎样?
这项技能说明,屏幕阅读器可能不会把该项目视为某个组的一部分,从而破坏导航。
它给出了哪些角色作为示例?
它提到了 list 中的 listitem、tablist 中的 tab,以及 menu 中的 menuitem。
该如何修复?
用适当的容器角色把项目包裹起来,例如在列表项外面包一层列表。
详情
作者的原始描述
Use when reviewing rendered HTML, interactive components, or design-system patterns related to Ensure ARIA roles are contained by required parent roles. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.
热度
- GitHub 星标
- 75k
- 排名
- #2736
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。