Skip to content

Commit

Permalink
fix: generate unsupported aria roles and attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeyyy committed May 21, 2018
1 parent aa90155 commit 7315662
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 169 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ module.exports = function (grunt) {
'aria-supported': {
data: {
entry: 'lib/commons/aria/index.js',
destFile: 'doc/aria-supported.md'
destFile: 'doc/aria-supported.md',
listType: 'unsupported'
}
},
configure: {
Expand Down
28 changes: 25 additions & 3 deletions build/tasks/aria-supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'use strict';

const aQ = require('aria-query');
const { roles, aria: props } = require('aria-query');

module.exports = function (grunt) {
grunt.registerMultiTask(
Expand All @@ -10,23 +11,44 @@ module.exports = function (grunt) {
function () {
const entry = this.data.entry;
const destFile = this.data.destFile;
const listType = this.data.listType.toLowerCase(); // enum = 'supported', 'unsupported', 'all'

const axe = require('../../axe');

const ariaKeys = Array.from(props).map(([key]) => key)
const roleAriaKeys = Array.from(roles)
.reduce((out, [name, rule]) => {
return [...out, ...Object.keys(rule.props)]
}, []);
const aQaria = new Set(axe.utils.uniqueArray(roleAriaKeys, ariaKeys));

const getDiff = (base, subject) => {
return [...[...new Map([...base.entries()].sort())]]
.reduce((out, [key] = item) => {
return `${out} | ${key} | ${subject.includes(key) ? 'Yes' : 'No'} |\n`
switch(listType) {
case 'supported':
return subject.includes(key)
? `${out} | ${key} | Yes |\n`
: `${out}`
case 'unsupported':
return !subject.includes(key)
? `${out} | ${key} | No |\n`
: `${out}`
case 'all':
default:
return `${out} | ${key} | ${subject.includes(key) ? 'Yes' : 'No'} |\n`;
}
}, ``);
}

const getMdContent = (roles, attributes) => {
return `# ARIA Roles and Attributes supported by axe-core \n \n## Roles\n \n| aria-role | axe-core support | \n| :------- | :------- | \n${roles} \n## Attributes \n \n| aria-attribute | axe-core support| \n| :------- | :------- | \n${attributes}`;
return `# ARIA Roles and Attributes ${listType === 'all' ? 'available': listType} in axe-core \n \n## Roles\n \n| aria-role | axe-core support | \n| :------- | :------- | \n${roles} \n## Attributes \n \n| aria-attribute | axe-core support| \n| :------- | :------- | \n${attributes}`;
}

const generateDoc = () => {
const content = getMdContent(
getDiff(aQ.roles, Object.keys(axe.commons.aria.lookupTable.role)),
getDiff(aQ.aria, Object.keys(axe.commons.aria.lookupTable.attributes))
getDiff(aQaria, Object.keys(axe.commons.aria.lookupTable.attributes))
);
grunt.file.write(destFile, content)
}
Expand Down
168 changes: 3 additions & 165 deletions doc/aria-supported.md
Original file line number Diff line number Diff line change
@@ -1,177 +1,15 @@
# ARIA Roles and Attributes supported by axe-core
# ARIA Roles and Attributes unsupported in axe-core

## Roles

| aria-role | axe-core support |
| :------- | :------- |
| alert | Yes |
| alertdialog | Yes |
| application | Yes |
| article | Yes |
| banner | Yes |
| button | Yes |
| cell | Yes |
| checkbox | Yes |
| columnheader | Yes |
| combobox | Yes |
| command | Yes |
| complementary | Yes |
| composite | Yes |
| contentinfo | Yes |
| definition | Yes |
| dialog | Yes |
| directory | Yes |
| doc-abstract | Yes |
| doc-acknowledgments | Yes |
| doc-afterword | Yes |
| doc-appendix | Yes |
| doc-backlink | Yes |
| doc-biblioentry | Yes |
| doc-bibliography | Yes |
| doc-biblioref | Yes |
| doc-chapter | Yes |
| doc-colophon | Yes |
| doc-conclusion | Yes |
| doc-cover | Yes |
| doc-credit | Yes |
| doc-credits | Yes |
| doc-dedication | Yes |
| doc-endnote | Yes |
| doc-endnotes | Yes |
| doc-epigraph | Yes |
| doc-epilogue | Yes |
| doc-errata | Yes |
| doc-example | Yes |
| doc-footnote | Yes |
| doc-foreword | Yes |
| doc-glossary | Yes |
| doc-glossref | Yes |
| doc-index | Yes |
| doc-introduction | Yes |
| doc-noteref | Yes |
| doc-notice | Yes |
| doc-pagebreak | Yes |
| doc-pagelist | Yes |
| doc-part | Yes |
| doc-preface | Yes |
| doc-prologue | Yes |
| doc-pullquote | Yes |
| doc-qna | Yes |
| doc-subtitle | Yes |
| doc-tip | Yes |
| doc-toc | Yes |
| document | Yes |
| feed | Yes |
| figure | No |
| form | Yes |
| grid | Yes |
| gridcell | Yes |
| group | Yes |
| heading | Yes |
| img | Yes |
| input | Yes |
| landmark | Yes |
| link | Yes |
| list | Yes |
| listbox | Yes |
| listitem | Yes |
| log | Yes |
| main | Yes |
| marquee | Yes |
| math | Yes |
| menu | Yes |
| menubar | Yes |
| menuitem | Yes |
| menuitemcheckbox | Yes |
| menuitemradio | Yes |
| navigation | Yes |
| none | Yes |
| note | Yes |
| option | Yes |
| presentation | Yes |
| progressbar | Yes |
| radio | Yes |
| radiogroup | Yes |
| range | Yes |
| region | Yes |
| roletype | Yes |
| row | Yes |
| rowgroup | Yes |
| rowheader | Yes |
| scrollbar | Yes |
| search | Yes |
| searchbox | Yes |
| section | Yes |
| sectionhead | Yes |
| select | Yes |
| separator | Yes |
| slider | Yes |
| spinbutton | Yes |
| status | Yes |
| structure | Yes |
| switch | Yes |
| tab | Yes |
| table | Yes |
| tablist | Yes |
| tabpanel | Yes |
| term | Yes |
| textbox | Yes |
| timer | Yes |
| toolbar | Yes |
| tooltip | Yes |
| tree | Yes |
| treegrid | Yes |
| treeitem | Yes |
| widget | Yes |
| window | Yes |

## Attributes

| aria-attribute | axe-core support|
| :------- | :------- |
| aria-activedescendant | Yes |
| aria-atomic | Yes |
| aria-autocomplete | Yes |
| aria-busy | Yes |
| aria-checked | Yes |
| aria-colcount | Yes |
| aria-colindex | Yes |
| aria-colspan | Yes |
| aria-controls | Yes |
| aria-current | Yes |
| aria-describedby | Yes |
| aria-disabled | Yes |
| aria-dropeffect | Yes |
| aria-expanded | Yes |
| aria-flowto | Yes |
| aria-grabbed | Yes |
| aria-haspopup | Yes |
| aria-hidden | Yes |
| aria-invalid | Yes |
| aria-keyshortcuts | Yes |
| aria-label | Yes |
| aria-labelledby | Yes |
| aria-level | Yes |
| aria-live | Yes |
| aria-modal | Yes |
| aria-multiline | Yes |
| aria-multiselectable | Yes |
| aria-orientation | Yes |
| aria-owns | Yes |
| aria-placeholder | Yes |
| aria-posinset | Yes |
| aria-pressed | Yes |
| aria-readonly | Yes |
| aria-relevant | Yes |
| aria-required | Yes |
| aria-describedat | No |
| aria-details | No |
| aria-roledescription | No |
| aria-rowcount | Yes |
| aria-rowindex | Yes |
| aria-rowspan | Yes |
| aria-selected | Yes |
| aria-setsize | Yes |
| aria-sort | Yes |
| aria-valuemax | Yes |
| aria-valuemin | Yes |
| aria-valuenow | Yes |
| aria-valuetext | Yes |

0 comments on commit 7315662

Please sign in to comment.