Skip to content

Commit

Permalink
fix(aXe): description list item does not have a <dl> parent
Browse files Browse the repository at this point in the history
aXe v2.x uses an equality check based on the uppercase `tagName`
property, but this latter is case-sensitive in XHTML.

This change patches aXe until a PR is submitted to fix dequelabs/axe-core#581

Fixes #114
  • Loading branch information
rdeltour committed Dec 13, 2017
1 parent 03e3a3e commit 4c0afdd
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/ace-core/src/checker/checker-chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const scripts = [
require.resolve('../scripts/vendor/outliner.min.js'),
require.resolve('../scripts/axe-patch-getselector.js'),
require.resolve('../scripts/axe-patch-arialookuptable.js'),
require.resolve('../scripts/axe-patch-dlitem.js'),
require.resolve('../scripts/ace-axe.js'),
require.resolve('../scripts/ace-extraction.js'),
];
Expand Down
8 changes: 8 additions & 0 deletions packages/ace-core/src/scripts/axe-patch-dlitem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

(function axePatch(window) {
const axe = window.axe;
axe._audit.checks.dlitem.evaluate = function evaluate(node, options) {
return node.parentNode.nodeName.toUpperCase() === 'DL';
}
}(window));
5 changes: 5 additions & 0 deletions tests/__tests__/regression.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ test('issue #108: HTML5Outline is not defined (RequireJS conflict)', async () =>
const report = await ace('../data/issue-108');
expect(report['earl:result']['earl:outcome']).toEqual('pass');
});

test('issue #114: Description list item does not have a <dl> parent element', async () => {
const report = await ace('../data/issue-114');
expect(report['earl:result']['earl:outcome']).toEqual('pass');
});
19 changes: 19 additions & 0 deletions tests/data/issue-114/EPUB/content_001.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
<head>
<title>Minimal EPUB</title>
<script src="../../../../node_modules/axe-core/axe.js"></script>
</head>
<body>
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
<dl>
<dt>term</dt>
<dd>def</dd>
</dl>
<script>
window.axe.run({ runOnly: { type: 'rule', values: ['dlitem'] } }, function (err, results) {
console.log(results);
});
</script>
</body>
</html>
12 changes: 12 additions & 0 deletions tests/data/issue-114/EPUB/nav.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
<head>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
23 changes: 23 additions & 0 deletions tests/data/issue-114/EPUB/package.opf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="uid">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="uid">NOID</dc:identifier>
<meta property="dcterms:modified">2017-01-01T00:00:01Z</meta>
<meta property="schema:accessibilityFeature">structuralNavigation</meta>
<meta property="schema:accessibilitySummary">everything OK!</meta>
<meta property="schema:accessibilityHazard">noFlashingHazard</meta>
<meta property="schema:accessibilityHazard">noSoundHazard</meta>
<meta property="schema:accessibilityHazard">noMotionSimulationHazard</meta>
<meta property="schema:accessMode">textual</meta>
<meta property="schema:accessModeSufficient">textual</meta>
</metadata>
<manifest>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
6 changes: 6 additions & 0 deletions tests/data/issue-114/META-INF/container.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
1 change: 1 addition & 0 deletions tests/data/issue-114/mimetype
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip

0 comments on commit 4c0afdd

Please sign in to comment.