From 4279c72b98cf2bd2cee643f7123a3017eeddd2ab Mon Sep 17 00:00:00 2001 From: Jey Date: Fri, 28 Sep 2018 17:29:36 +0100 Subject: [PATCH] fix: html-lang-valid should consider xml:lang (#1152) This PR enhances `html-lang-valid` rule to allow `xml:lang` attribute. Closes issue: - https://github.com/dequelabs/axe-core/issues/1140 ## Reviewer checks **Required fields, to be filled out by PR reviewer(s)** - [x] Follows the commit message policy, appropriate for next version - [x] Has documentation updated, a DU ticket, or requires no documentation change - [x] Includes new tests, or was unnecessary - [x] Code is reviewed for security by: @WilcoFiers --- lib/rules/html-lang-valid.json | 2 +- .../full/html-lang-valid/frames/level1.html | 2 ++ .../full/html-lang-valid/frames/level2-b.html | 11 ++++++++ .../full/html-lang-valid/frames/level2-c.html | 11 ++++++++ .../full/html-lang-valid/html-lang-valid.html | 3 ++ .../full/html-lang-valid/html-lang-valid.js | 28 ++++++++++++++++--- 6 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 test/integration/full/html-lang-valid/frames/level2-b.html create mode 100644 test/integration/full/html-lang-valid/frames/level2-c.html diff --git a/lib/rules/html-lang-valid.json b/lib/rules/html-lang-valid.json index 71115a6007..050b10f605 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]", + "selector": "html[lang], html[xml\\:lang]", "tags": [ "cat.language", "wcag2a", diff --git a/test/integration/full/html-lang-valid/frames/level1.html b/test/integration/full/html-lang-valid/frames/level1.html index 644f7ce0df..af5b58fa40 100644 --- a/test/integration/full/html-lang-valid/frames/level1.html +++ b/test/integration/full/html-lang-valid/frames/level1.html @@ -8,5 +8,7 @@ + + diff --git a/test/integration/full/html-lang-valid/frames/level2-b.html b/test/integration/full/html-lang-valid/frames/level2-b.html new file mode 100644 index 0000000000..fbd8390b7d --- /dev/null +++ b/test/integration/full/html-lang-valid/frames/level2-b.html @@ -0,0 +1,11 @@ + + + + No lang test + + + + + Hi + + diff --git a/test/integration/full/html-lang-valid/frames/level2-c.html b/test/integration/full/html-lang-valid/frames/level2-c.html new file mode 100644 index 0000000000..8cc3b292e9 --- /dev/null +++ b/test/integration/full/html-lang-valid/frames/level2-c.html @@ -0,0 +1,11 @@ + + + + No lang test + + + + + Hi + + diff --git a/test/integration/full/html-lang-valid/html-lang-valid.html b/test/integration/full/html-lang-valid/html-lang-valid.html index a4242c0bd4..e1cb33dee1 100644 --- a/test/integration/full/html-lang-valid/html-lang-valid.html +++ b/test/integration/full/html-lang-valid/html-lang-valid.html @@ -1,5 +1,6 @@ + html-lang-valid test @@ -16,10 +17,12 @@ var assert = chai.assert; +
+ diff --git a/test/integration/full/html-lang-valid/html-lang-valid.js b/test/integration/full/html-lang-valid/html-lang-valid.js index 63676a8539..a7e75d8afe 100644 --- a/test/integration/full/html-lang-valid/html-lang-valid.js +++ b/test/integration/full/html-lang-valid/html-lang-valid.js @@ -1,6 +1,8 @@ describe('html-lang-valid test', function() { 'use strict'; + var results; + before(function(done) { axe.testUtils.awaitNestedLoad(function() { axe.run( @@ -15,15 +17,17 @@ describe('html-lang-valid test', function() { }); describe('violations', function() { - it('should find 2', function() { - assert.lengthOf(results.violations[0].nodes, 2); + it('should find 3', function() { + assert.lengthOf(results.violations[0].nodes, 3); }); + it('should find first level iframe', function() { assert.deepEqual(results.violations[0].nodes[0].target, [ '#frame1', '#violation1' ]); }); + it('should find second level iframe', function() { assert.deepEqual(results.violations[0].nodes[1].target, [ '#frame1', @@ -31,11 +35,19 @@ describe('html-lang-valid test', function() { '#violation2' ]); }); + + it('should find #violation2c', function() { + assert.deepEqual(results.violations[0].nodes[2].target, [ + '#frame1', + '#frame5', + '#violation2c' + ]); + }); }); describe('passes', function() { - it('should find 1', function() { - assert.lengthOf(results.passes[0].nodes, 1); + it('should find 2', function() { + assert.lengthOf(results.passes[0].nodes, 2); }); it('should find #pass1', function() { @@ -45,5 +57,13 @@ describe('html-lang-valid test', function() { '#pass1' ]); }); + + it('should find #pass2b', function() { + assert.deepEqual(results.passes[0].nodes[1].target, [ + '#frame1', + '#frame4', + '#pass2b' + ]); + }); }); });