简体   繁体   English

WAI-ARIA:Javascript能力测试?

[英]WAI-ARIA: Javascript Capability Testing?

In the spirit of progressive enhancement, I'd like to do some ARIA capabilities testing to implement additional enhancements if they're supported by the browser. 本着渐进式增强的精神,我想做一些ARIA功能测试,以便在浏览器支持的情况下实现其他增强功能。 I'm not looking to detect screen readers—I'm looking to ensure that screen reader users will get the optimal experience given the tools that they're using. 我不打算检测屏幕阅读器 - 我希望确保屏幕阅读器用户在他们使用的工具的情况下获得最佳体验。

For example, if the aria-live attribute is not supported, then it may not be a good idea to implement endless scrolling . 例如,如果不支持aria-live属性,那么实现无限滚动可能不是一个好主意。

I'm aware that there's an additional concern that browsers may support these attributes but the screen reader may not. 我知道还有一个问题,浏览器可能支持这些属性,但屏幕阅读器可能不支持。 Since screen readers run transparently over browsers, I'm okay with that edge case being ignored. 由于屏幕阅读器在浏览器上透明地运行,我可以忽略该边缘情况。

I've never heard of anyone doing anything like this. 我从来没有听说有人这样做过。 Is it as easy as testing for additional DOM properties endowed by browsers? 它是否像测试浏览器赋予的其他DOM属性一样简单? Do one of Mark Pilgrim's other capability testing techniques work here? Mark Pilgrim的其他功能测试技术之一在这里工作吗?

Thanks! 谢谢!

The first answer has some incorrect information. 第一个答案有一些不正确的信息。 Certain browsers do support WAI-ARIA and some don't. 某些浏览器确实支持WAI-ARIA,有些则不支持。 Browsers send events to screen readers via the operating system's accessibility API. 浏览器通过操作系统的辅助功能API向屏幕阅读器发送事件。 If you use IE 7, for example, it cannot deal with WAI-ARIA where IE 8 can. 例如,如果您使用IE 7,则无法处理IE 8可以使用的WAI-ARIA。 Look at this graphic 看看这个图

That being said, you can't do testing to determine what tags are supported. 话虽这么说,你不能做测试来确定支持哪些标签。 In general, limited WAI-ARIA support began in FF2 and IE8. 一般来说,有限的WAI-ARIA支持始于FF2和IE8。 Look at the release notes of the browser to determine what WAI-ARIA support it has. 查看浏览器的发行说明,以确定它支持的WAI-ARIA。

Here is a link that details testing WAI-ARIA 这是一个详细测试WAI-ARIA的链接

I'm not looking to detect screen readers 我不打算检测屏幕阅读器

I'm sorry, but that's exactly what you're looking to do. 对不起,但这正是你要做的。 It is not possible to detect screen readers unless they expose themselves to content scripts in some way, and there are many different screen readers, so you shouldn't really try. 除非他们以某种方式将自己暴露给内容脚本,并且有许多不同的屏幕阅读器,否则无法检测到屏幕阅读器,因此您不应该尝试。 If anything, you might be able to get some hack working in browsers that support aural CSS to detect screen readers, but you're definitely not going to be able to detect if a certain ARIA feature is supported or not. 如果有的话,你可能会在支持听觉CSS的浏览器中使用hack来检测屏幕阅读器,但你绝对无法检测是否支持某种ARIA功能。

if the aria-live attribute is not supported 如果不支持aria-live属性

No browsers actually "support" ARIA more than just providing element property accessors in the DOM; 没有浏览器实际上“支持”ARIA而不仅仅是在DOM中提供元素属性访问器; only screen readers/assistive reading software supports ARIA, in that it actually uses the ARIA attributes to help the user interact with a website. 只有屏幕阅读器/辅助阅读软件支持ARIA,因为它实际上使用ARIA属性来帮助用户与网站进行交互。

正如@ ChrisMorgan的评论中所提到 ,Derek Featherstone的A List Apart关于优雅地实施ARIA的困难的文章是必读的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM