Skip to content

Commit

Permalink
feat: update Axe to v3.2.2 (#228)
Browse files Browse the repository at this point in the history
- remove the now unnecessary custom ARIA lookup table (since DPUB roles
  are now natively supported by Axe)
- in Ace checks, epub:type attribute selectors are replaced by javascript
  matchers, to work around a limitation of Axe's built-in CSS parser
- patch the `only-list-items` check, to allow roles subclassing
  `listitem` as children of lists
- patch the `aria.isAriaRoleAllowedOnElement` function to ensure that
  roles that do not explicitly define the elements their allowed on are
  evaluated
- disable `landmark-complementary-is-top-level`, which needs further
  review to see if it makes sense in EPUB.

Close #225
  • Loading branch information
rdeltour authored and danielweck committed May 3, 2019
1 parent 822469f commit acf95da
Show file tree
Hide file tree
Showing 8 changed files with 529 additions and 560 deletions.
2 changes: 1 addition & 1 deletion packages/ace-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@daisy/ace-report-axe": "^1.0.1",
"@daisy/epub-utils": "^1.0.2",
"@daisy/puppeteer-utils": "^1.0.0",
"axe-core": "~2.6.1",
"axe-core": "^3.2.2",
"file-url": "^2.0.2",
"h5o": "^0.11.3",
"p-map": "^1.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/ace-core/src/checker/checker-chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ tmp.setGracefulCleanup();
const scripts = [
path.resolve(require.resolve('axe-core'), '../axe.min.js'),
require.resolve('../scripts/vendor/outliner.min.js'),
require.resolve('../scripts/axe-patch-arialookuptable.js'),
require.resolve('../scripts/axe-patch-is-aria-role-allowed.js'),
require.resolve('../scripts/axe-patch-only-list-items.js'),
require.resolve('../scripts/ace-axe.js'),
require.resolve('../scripts/ace-extraction.js'),
];
Expand Down
20 changes: 17 additions & 3 deletions packages/ace-core/src/scripts/ace-axe.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ daisy.ace.run = function(done) {
rules: [
{
id: 'pagebreak-label',
selector: '[*|type~="pagebreak"], [role~="doc-pagebreak"]',
// selector: '[*|type~="pagebreak"], [role~="doc-pagebreak"]',
matches: function matches(node, virtualNode, context) {
return node.hasAttribute('role')
&& node.getAttribute('role').match(/\S+/g).includes('doc-pagebreak')
|| node.hasAttributeNS('http://www.idpf.org/2007/ops', 'type')
&& node.getAttributeNS('http://www.idpf.org/2007/ops', 'type').match(/\S+/g).includes('pagebreak')
},
any: ['aria-label', 'non-empty-title'],
metadata: {
description: "Ensure page markers have an accessible label",
Expand All @@ -172,7 +178,10 @@ daisy.ace.run = function(done) {
},
{
id: 'epub-type-has-matching-role',
selector: '[*|type]',
// selector: '[*|type]',
matches: function matches(node, virtualNode, context) {
return node.hasAttributeNS('http://www.idpf.org/2007/ops', 'type')
},
any: ['matching-aria-role'],
metadata: {
help: "ARIA role should be used in addition to epub:type",
Expand All @@ -183,7 +192,7 @@ daisy.ace.run = function(done) {
{
id: 'landmark-one-main',
all: [
"has-no-more-than-one-main"
"page-no-duplicate-main"
],
}
]
Expand All @@ -193,6 +202,11 @@ daisy.ace.run = function(done) {
{
"rules": {
"bypass": { enabled: false },
"region": { enabled: false },
"page-has-heading-one": { enabled: false },
// The following newer Axe rules need to be further reviewed
// to see if they're useful in an EPUB context
"landmark-complementary-is-top-level": { enabled: false },
}
},
function(axeError, axeResult) {
Expand Down
Loading

0 comments on commit acf95da

Please sign in to comment.