-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
08af138
commit e67a913
Showing
3 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
return node.parentNode.tagName === 'DL'; | ||
return node.parentNode.tagName.toUpperCase() === 'DL'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']); | ||
}); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title>axe.utils.getSelector test</title> | ||
<meta charset="utf-8"/> | ||
<link rel="stylesheet" type="text/css" href="/node_modules/mocha/mocha.css" /> | ||
<script src="/node_modules/mocha/mocha.js"></script> | ||
<script src="/node_modules/chai/chai.js"></script> | ||
<script src="/axe.js"></script> | ||
<script> | ||
mocha.setup({ | ||
timeout: 10000, | ||
ui: 'bdd' | ||
}); | ||
var assert = chai.assert; | ||
</script> | ||
</head> | ||
<body> | ||
<div id="fixture"> | ||
<dd id="uncontained">Should belong to a list.</dd> | ||
<dt id="alsouncontained">Should belong to a list.</dt> | ||
<dl> | ||
<dt id="contained">Does belong to a list.</dt> | ||
<dd id="alsocontained">Also belongs to a list.</dd> | ||
</dl> | ||
</div> | ||
<div id="mocha"></div> | ||
<script src="dlitem-xhtml.js"></script> | ||
<script src="/test/integration/adapter.js"></script> | ||
</body> | ||
</html> |