SVG 的默认 ARIA 角色是什么?

What is the default ARIA role for an SVG?

如果 role 属性不存在且文档包含可见图形,我一直在尝试确定 SVG 标签的默认角色。

使用 Chrome 的辅助工具,它告诉我角色是 SVGRoot:

然而,这不是一个有效的 ARIA 角色,它是 Chrome 在内部使用的自己的角色之一。

我已经能够通过此文档找到更多信息:WAI-ARIA Graphics Module,它指示允许在 SVG 标签上使用哪些角色,但我似乎无法缩小应该使用哪些角色的范围成为默认角色。

如果没有提供有效的 role 属性,用户代理应该假定 SVG 默认扮演什么角色?

SVG 本身没有隐含的 aria 角色,但是开发人员可以(并且可能应该)分配以下角色之一:applicationdocumentimg

如果您的 SVG 具有需要用户输入的可聚焦元素,请使用 application

如果您的 SVG 主要包含非交互式信息文本,请使用 document

如果您的 SVG 是纯视觉的或使用元素集合构成单个图像,请使用 img

来源:https://www.w3.org/TR/html-aria/#docconformance

根据 HTML 文档中的 ARIA,SVG has no default corresponding role

"No corresponding role"状态定义如下:

The elements marked with No corresponding role, in the second column of the table do not have any implicit ARIA semantics, but they do have meaning and this meaning may be represented in roles, states and properties not provided by ARIA, and exposed to users of assistive technology via accessibility APIs. It is therefore recommended that web developers add a role attribute to a semantically neutral element such as a div or span, rather than overriding the semantics of the listed elements.

正如@josh 已经回答的那样,SVG 元素允许的角色是 applicationdocumentimg