Skip to content

Commit

Permalink
Change html-lang-valid selector so the rule only applies when attrs h…
Browse files Browse the repository at this point in the history
…ave a value. Fix #3624
  • Loading branch information
thibaudcolas committed Oct 6, 2022
1 parent 8e03e2c commit 95b2224
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/html-lang-valid.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "html-lang-valid",
"selector": "html[lang], html[xml\\:lang]",
"selector": "html[lang]:not([lang=\"\"]), html[xml\\:lang]:not([xml\\:lang=\"\"])",
"tags": ["cat.language", "wcag2a", "wcag311", "ACT"],
"actIds": ["bf051a"],
"metadata": {
Expand Down
15 changes: 15 additions & 0 deletions test/integration/virtual-rules/html-lang-valid.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ describe('html-lang-valid virtual-rule', function() {
attributes: {}
});

assert.lengthOf(results.inapplicable, 1);
assert.lengthOf(results.passes, 0);
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.incomplete, 0);
});

it('is inapplicable with empty lang or xml:lang', function() {
// Error caught by html-has-lang instead
var results = axe.runVirtualRule('html-lang-valid', {
nodeName: 'html',
attributes: {
'lang': '',
}
});

assert.lengthOf(results.inapplicable, 1);
assert.lengthOf(results.passes, 0);
assert.lengthOf(results.violations, 0);
Expand Down

0 comments on commit 95b2224

Please sign in to comment.