Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors for WCAG2 1.3.1 F92,ARIA4 get reported even when using Section508 standard #280

Open
thibaudcolas opened this issue May 13, 2020 · 0 comments
Assignees

Comments

@thibaudcolas
Copy link

thibaudcolas commented May 13, 2020

While using HTML CS with the Section508 ruleset, I got errors for code Section508.undefined.F92,ARIA4:

[HTMLCS] Error|Section508.undefined.F92,ARIA4|li|
|This element's role is "presentation" but contains child elements with semantic meaning.
|<li class="nav__item nav__item--primary" role="presentation">...</li>

The error is correct but its code is very strange – "undefined", and the fact that F92 ARIA4 is WCAG terminology, not Section508. Digging through the code, I see that this is because this particular rule runs regardless of the loaded standard:

HTML_CodeSniffer/HTMLCS.js

Lines 291 to 298 in 0be3ec3

// Due to filtering of presentation roles for general sniffing these need to be handled
// separately. The 1.3.1 sniff needs to run to detect any incorrect usage of the presentation
// role.
var presentationElems = topElement.querySelectorAll('[role="presentation"]');
_currentSniff = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1;
[].forEach.call(presentationElems, function(element) {
_currentSniff.testSemanticPresentationRole(element);
});

Should this check be skipped if the loaded standard is Section508?


Here is a script to reproduce this based on the one from the README:

const puppeteer = require("puppeteer-core");

// Replace with the path to the chrome executable in your file system. This one assumes MacOSX.
const executablePath =
  "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";

// Replace with the url you wish to test.
const url = "https://www.rca.ac.uk/";

(async () => {
  const browser = await puppeteer.launch({
    executablePath,
  });

  const page = await browser.newPage();

  page.on("console", (msg) => {
    console.log(msg.text());
  });

  await page.goto(url);

  await page.addScriptTag({
    path: "node_modules/html_codesniffer/build/HTMLCS.js",
  });

  await page.evaluate(function () {
    HTMLCS_RUNNER.run("Section508");
  });

  await browser.close();
})();
@ironikart ironikart self-assigned this May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants