diff options
author | Trevor Elliott <trevor@galois.com> | 2013-06-24 13:40:42 -0700 |
---|---|---|
committer | Trevor Elliott <trevor@galois.com> | 2013-06-24 13:40:42 -0700 |
commit | 1bf5409ef45872e84f62d2199b918ab233461aed (patch) | |
tree | 9f0df3378c0f2fe226104783be9a8e5296d3b30e /guidelines/accessibility | |
parent | a1100b640f2ed9469158cb0bc42f2f9bf288f917 (diff) |
Start work on implmenting the W3C accessibilty guidelines
Diffstat (limited to 'guidelines/accessibility')
-rw-r--r-- | guidelines/accessibility/conformance-A.json | 7 | ||||
-rw-r--r-- | guidelines/accessibility/guideline-1.js | 30 |
2 files changed, 37 insertions, 0 deletions
diff --git a/guidelines/accessibility/conformance-A.json b/guidelines/accessibility/conformance-A.json new file mode 100644 index 0000000..5aa5bf3 --- /dev/null +++ b/guidelines/accessibility/conformance-A.json @@ -0,0 +1,7 @@ +{ "name": "W3C Accessibility Guidelines (Conformance A)" +, "description": "See: www.w3.org/TR/WCAG10/" +, "license": "BSD3" +, "rules": + [ "guideline-1.js" + ] +} 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')); +}; |