From 1bf5409ef45872e84f62d2199b918ab233461aed Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Mon, 24 Jun 2013 13:40:42 -0700 Subject: Start work on implmenting the W3C accessibilty guidelines See http://www.w3.org/TR/WCAG10/#Guidelines --- guidelines/accessibility/conformance-A.json | 7 +++++++ guidelines/accessibility/guideline-1.js | 30 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 guidelines/accessibility/conformance-A.json create mode 100644 guidelines/accessibility/guideline-1.js 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')); +}; -- cgit v1.2.3