From 95b22241389791fe875464e9ec3e729375743625 Mon Sep 17 00:00:00 2001 From: Thibaud Colas Date: Sat, 17 Sep 2022 16:29:13 +0100 Subject: [PATCH 1/2] Change html-lang-valid selector so the rule only applies when attrs have a value. Fix #3624 --- lib/rules/html-lang-valid.json | 2 +- test/integration/virtual-rules/html-lang-valid.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/rules/html-lang-valid.json b/lib/rules/html-lang-valid.json index 19fd4c01c9..5cf81f4325 100644 --- a/lib/rules/html-lang-valid.json +++ b/lib/rules/html-lang-valid.json @@ -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": { diff --git a/test/integration/virtual-rules/html-lang-valid.js b/test/integration/virtual-rules/html-lang-valid.js index d89d410ca6..8e7675a7a2 100644 --- a/test/integration/virtual-rules/html-lang-valid.js +++ b/test/integration/virtual-rules/html-lang-valid.js @@ -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); From c21dac78980d73f9d5099e85d4279ef156af0692 Mon Sep 17 00:00:00 2001 From: Steven Lambert Date: Tue, 22 Nov 2022 09:57:41 -0700 Subject: [PATCH 2/2] add integration tests --- .../full/html-lang-valid/frames/level1.html | 2 ++ .../full/html-lang-valid/frames/level2-d.html | 11 +++++++++++ .../full/html-lang-valid/frames/level2-e.html | 11 +++++++++++ 3 files changed, 24 insertions(+) create mode 100644 test/integration/full/html-lang-valid/frames/level2-d.html create mode 100644 test/integration/full/html-lang-valid/frames/level2-e.html diff --git a/test/integration/full/html-lang-valid/frames/level1.html b/test/integration/full/html-lang-valid/frames/level1.html index e35f20b5e4..77b6b5478d 100644 --- a/test/integration/full/html-lang-valid/frames/level1.html +++ b/test/integration/full/html-lang-valid/frames/level1.html @@ -10,5 +10,7 @@ + + diff --git a/test/integration/full/html-lang-valid/frames/level2-d.html b/test/integration/full/html-lang-valid/frames/level2-d.html new file mode 100644 index 0000000000..b7ddbb9488 --- /dev/null +++ b/test/integration/full/html-lang-valid/frames/level2-d.html @@ -0,0 +1,11 @@ + + + + No lang test + + + + + Empty lang + + diff --git a/test/integration/full/html-lang-valid/frames/level2-e.html b/test/integration/full/html-lang-valid/frames/level2-e.html new file mode 100644 index 0000000000..4a732735b0 --- /dev/null +++ b/test/integration/full/html-lang-valid/frames/level2-e.html @@ -0,0 +1,11 @@ + + + + No lang test + + + + + Empty xml:lang + +