diff options
Diffstat (limited to 'guidelines/accessibility/guideline-1.js')
-rw-r--r-- | guidelines/accessibility/guideline-1.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/guidelines/accessibility/guideline-1.js b/guidelines/accessibility/guideline-1.js new file mode 100644 index 0000000..35b3d89 --- /dev/null +++ b/guidelines/accessibility/guideline-1.js @@ -0,0 +1,30 @@ +/** + * Provide equivalent alternatives to auditory and visual content + */ + +exports.name = "Equivalent Alternatives"; +exports.description = ""; + +exports.rule = function(report) { + + var hasAlt = function(type) { + return function(ix) { + if(_.isEmpty($(this).attr('alt'))) { + report.error('No alt text specified for ' + type + ' element', this); + } + }; + }; + + // We treat anchors with images as a child as things that should contain + // alternatives. + $5('a').find('img').each(hasAlt('img')); + + // All input tags must have an alt attribute. + $5('input').each(hasAlt('input')); + + // All applet tags must have an alt attribute. + $5('applet').each(hasAlt('applet')); + + // All object tags must have an alt attribute. + $5('object').each(hasAlt('applet')); +}; |