From e67a913e8fcb3930ea2625eecb1749e17b0cc4ad Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Fri, 15 Dec 2017 17:24:24 +0100 Subject: [PATCH] fix(rule/dlitem): use a case-insenstive `tagName` test (#652) In XHTML, `element.tagName` preserves the case. In the `dlitem` check, the tag name is now upper-cased before being tested as 'DL', to make the rule work on XHTML documents. Fixes #581 --- lib/checks/lists/dlitem.js | 2 +- .../full/definition-list/dlitem-xhtml.js | 52 +++++++++++++++++++ .../full/definition-list/dlitem-xhtml.xhtml | 30 +++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 test/integration/full/definition-list/dlitem-xhtml.js create mode 100644 test/integration/full/definition-list/dlitem-xhtml.xhtml diff --git a/lib/checks/lists/dlitem.js b/lib/checks/lists/dlitem.js index 96ec9e65b1..b759d2de5d 100644 --- a/lib/checks/lists/dlitem.js +++ b/lib/checks/lists/dlitem.js @@ -1,2 +1,2 @@ -return node.parentNode.tagName === 'DL'; +return node.parentNode.tagName.toUpperCase() === 'DL'; diff --git a/test/integration/full/definition-list/dlitem-xhtml.js b/test/integration/full/definition-list/dlitem-xhtml.js new file mode 100644 index 0000000000..ee1e716bf6 --- /dev/null +++ b/test/integration/full/definition-list/dlitem-xhtml.js @@ -0,0 +1,52 @@ + +describe('dlitem XHTML test', function () { + 'use strict'; + + var results; + + before(function (done) { + axe.run({ runOnly: { type: 'rule', values: ['dlitem'] } }, function (err, r) { + assert.isNull(err); + results = r; + done(); + }); + }); + + describe('violations', function() { + + it('should find 2', function () { + assert.lengthOf(results.violations, 1); + assert.lengthOf(results.violations[0].nodes, 2); + }); + + it('should find #uncontained and #also', function () { + assert.equal(results.violations[0].nodes[0].any[0].id, 'dlitem'); + assert.deepEqual(results.violations[0].nodes[0].target, ['#uncontained']); + }); + + it('should find #alsouncontained', function () { + assert.equal(results.violations[0].nodes[1].any[0].id, 'dlitem'); + assert.deepEqual(results.violations[0].nodes[1].target, ['#alsouncontained']); + }); + + }); + + describe('passes', function() { + + it('should find 2', function () { + assert.lengthOf(results.passes, 1); + assert.lengthOf(results.passes[0].nodes, 2); + }); + + it('should find #uncontained and #also', function () { + assert.equal(results.passes[0].nodes[0].any[0].id, 'dlitem'); + assert.deepEqual(results.passes[0].nodes[0].target, ['#contained']); + }); + + it('should find #alsouncontained', function () { + assert.equal(results.passes[0].nodes[1].any[0].id, 'dlitem'); + assert.deepEqual(results.passes[0].nodes[1].target, ['#alsocontained']); + }); + + }); +}); diff --git a/test/integration/full/definition-list/dlitem-xhtml.xhtml b/test/integration/full/definition-list/dlitem-xhtml.xhtml new file mode 100644 index 0000000000..6367a9289f --- /dev/null +++ b/test/integration/full/definition-list/dlitem-xhtml.xhtml @@ -0,0 +1,30 @@ + + + axe.utils.getSelector test + + + + + + + + +
+
Should belong to a list.
+
Should belong to a list.
+
+
Does belong to a list.
+
Also belongs to a list.
+
+
+
+ + + +