WordPress-Coding-Standards icon indicating copy to clipboard operation
WordPress-Coding-Standards copied to clipboard

A11y: Restrict title attribute to iframe element

Open GaryJones opened this issue 9 years ago • 7 comments

I'd like to consider what sniffs could be written that address programatically testable accessibility concerns.

The first is to check for the use of the title attribute, and flag it as an error, if it's not inside an iframe element.

This may well be covered with the theme check sniffs, but wanted to get discussion on this started anyway.

cc @afercia.

GaryJones avatar Jul 16 '16 07:07 GaryJones

Related issue for the theme check sniffs: https://github.com/WPTRT/WordPress-Coding-Standards/issues/25

jrfnl avatar Jul 16 '16 07:07 jrfnl

I think https://github.com/WPTRT/WordPress-Coding-Standards/issues/25 covers the document title (<title> tag) while @GaryJones is considering the title attribute. 😉

afercia avatar Jul 16 '16 18:07 afercia

I started with the simple case, but with known errors of false positives.

I guess the issue here is how best to work out if title= is found inside a HTML tag.

GaryJones avatar Jul 17 '16 16:07 GaryJones

Testing for ' title=' with a leading space could maybe reduce some false positives (at least that's what I do when scanning the WP codebase). But it could also be a line break or a tabulation...

afercia avatar Jul 18 '16 07:07 afercia

I have been unsuccessful in reducing the false positives for WPTRT#25 ( Which is why I have not done a PR) . Perhaps we can resort to a warning, and a note that a manual check is required? Not awesome but easier. -We need to search for php as well, not only inline html, just in case.

carolinan avatar Jul 19 '16 16:07 carolinan

@carolinan If your remark relates to https://github.com/WPTRT/WordPress-Coding-Standards/issues/25, you might get better feedback if you post your comment in the issue there ?

jrfnl avatar Jul 19 '16 17:07 jrfnl

I added it here because the issues are and the sollutions will be very similar. Just confirming that I have not found a quick sollution for the false positives either.

I am not sure how you feel about this or how you have handled similar checks in the past. What I meant was that with these false positives, the sniff could be added as warning, not an error.

This test is missing a check for the title attribute in php, it only checks the inline html.

carolinan avatar Jul 19 '16 18:07 carolinan