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

fix(html-lang-valid): only run rule when attribute has value #3663

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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