Skip to content

Commit fdc7122

Browse files
authored
Chore: Disable axe-core svg-img-alt rule by default
Disabled due to false positives in jsdom. - - - - - - - - - - - - - - - - - - - - Fix #5030 Close #5075
1 parent 99ad46d commit fdc7122

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

packages/hint-axe/scripts/create/utils.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ const { startCase } = require('lodash');
44

55
/** @typedef {import('axe-core').RuleMetadata} RuleMeta */
66

7+
/**
8+
* Additional rules which are disabled by default.
9+
* Typically these are added because the rule doesn't
10+
* work correctly in some or all webhint contexts.
11+
*/
12+
const disabledRules = new Set([
13+
/**
14+
* Disabled due to false-positives in jsdom contexts.
15+
* Occurs because jsdom reports `display: none` for `<svg><title>`.
16+
* See https://github.com/webhintio/hint/issues/5030.
17+
*/
18+
'svg-img-alt'
19+
]);
20+
721
/**
822
* @param {string} str
923
*/
@@ -33,7 +47,7 @@ const escapeKey = (id) => {
3347
* @param {RuleMeta} rule
3448
*/
3549
const isRuleDisabled = (rule) => {
36-
return rule.tags.includes('experimental') || rule.tags.every((tag) => {
50+
return disabledRules.has(rule.ruleId) || rule.tags.includes('experimental') || rule.tags.every((tag) => {
3751
return !tag.startsWith('wcag');
3852
});
3953
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { generateHTMLPage } from '@hint/utils-create-server';
2+
import { getHintPath, HintTest, testHint } from '@hint/utils-tests-helpers';
3+
4+
const hintPath = getHintPath(__filename, true);
5+
6+
const html = {
7+
role: generateHTMLPage(undefined, `
8+
<div>
9+
<h1>test</h1>
10+
<svg role="img"><title>test</title></svg>
11+
</div>`)
12+
};
13+
14+
const tests: HintTest[] = [
15+
{
16+
name: `HTML passes an svg with role`,
17+
serverConfig: html.role
18+
}
19+
];
20+
21+
testHint(hintPath, tests);

0 commit comments

Comments
 (0)