跳到正文
Skillpedia
网站与界面(前端)75k · #2736

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/aria-required-parent/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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 (like list)
  • 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.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2736
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能