Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(standards): add html elems object #2325

Closed
wants to merge 15 commits into from
2 changes: 2 additions & 0 deletions lib/core/base/audit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Rule from './rule';
import Check from './check';
import standards from '../../standards';
import RuleResult from './rule-result';
import {
clone,
Expand Down Expand Up @@ -152,6 +153,7 @@ class Audit {
this.tagExclude = ['experimental'];
this.lang = 'en';
this.defaultConfig = audit;
this.standards = standards;
this._init();
// A copy of the "default" locale. This will be set if the user
// provides a new locale to `axe.configure()` and used to undo
Expand Down
5 changes: 5 additions & 0 deletions lib/core/public/configure.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { hasReporter } from './reporter';
import { configureStandards } from '../../standards';

function configure(spec) {
'use strict';
Expand Down Expand Up @@ -106,6 +107,10 @@ function configure(spec) {
if (spec.locale) {
audit.applyLocale(spec.locale);
}

if (spec.standards) {
configureStandards(spec.standards);
}
}

export default configure;
4 changes: 3 additions & 1 deletion lib/core/public/reset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*global axe */
import { resetStandards } from '../../standards';

function reset() {
'use strict';
var audit = axe._audit;
Expand All @@ -7,6 +8,7 @@ function reset() {
throw new Error('No audit configured');
}
audit.resetRulesAndChecks();
resetStandards();
}

export default reset;
200 changes: 200 additions & 0 deletions lib/standards/aria-attrs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
// Source: https://www.w3.org/TR/wai-aria-1.1/#states_and_properties
const ariaAttrs = {
'aria-activedescendant': {
type: 'idref',
allowEmpty: true
},
'aria-atomic': {
type: 'boolean',
global: true
},
'aria-autocomplete': {
type: 'nmtoken',
values: ['inline', 'list', 'both', 'none']
},
'aria-busy': {
type: 'boolean',
global: true
},
'aria-checked': {
type: 'nmtoken',
values: ['false', 'mixed', 'true', 'undefined']
},
'aria-colcount': {
type: 'int'
},
'aria-colindex': {
type: 'int'
},
'aria-colspan': {
type: 'int'
},
'aria-controls': {
type: 'idrefs',
allowEmpty: true,
global: true
},
'aria-current': {
type: 'nmtoken',
allowEmpty: true,
values: ['page', 'step', 'location', 'date', 'time', 'true', 'false'],
global: true
},
'aria-describedby': {
type: 'idrefs',
allowEmpty: true,
global: true
},
'aria-details': {
type: 'idref',
allowEmpty: true,
global: true
},
'aria-disabled': {
type: 'boolean',
global: true
},
'aria-dropeffect': {
type: 'nmtokens',
values: ['copy', 'execute', 'link', 'move', 'none', 'popup'],
global: true
},
'aria-errormessage': {
type: 'idref',
allowEmpty: true,
global: true
},
'aria-expanded': {
type: 'nmtoken',
values: ['true', 'false', 'undefined']
},
'aria-flowto': {
type: 'idrefs',
allowEmpty: true,
global: true
},
'aria-grabbed': {
type: 'nmtoken',
values: ['true', 'false', 'undefined'],
global: true
},
'aria-haspopup': {
type: 'nmtoken',
allowEmpty: true,
values: ['true', 'false', 'menu', 'listbox', 'tree', 'grid', 'dialog'],
global: true
},
'aria-hidden': {
type: 'nmtoken',
values: ['true', 'false', 'undefined'],
global: true
},
'aria-invalid': {
type: 'nmtoken',
allowEmpty: true,
values: ['grammar', 'false', 'spelling', 'true'],
global: true
},
'aria-keyshortcuts': {
type: 'string',
allowEmpty: true,
global: true
},
'aria-label': {
type: 'string',
allowEmpty: true,
global: true
},
'aria-labelledby': {
type: 'idrefs',
allowEmpty: true,
global: true
},
'aria-level': {
type: 'int'
},
'aria-live': {
type: 'nmtoken',
values: ['assertive', 'off', 'polite'],
global: true
},
'aria-modal': {
type: 'boolean'
},
'aria-multiline': {
type: 'boolean'
},
'aria-multiselectable': {
type: 'boolean'
},
'aria-orientation': {
type: 'nmtoken',
values: ['horizontal', 'undefined', 'vertical']
},
'aria-owns': {
type: 'idrefs',
allowEmpty: true,
global: true
},
'aria-placeholder': {
type: 'string',
allowEmpty: true
},
'aria-posinset': {
type: 'int'
},
'aria-pressed': {
type: 'nmtoken',
values: ['false', 'mixed', 'true', 'undefined']
},
'aria-readonly': {
type: 'boolean'
},
'aria-relevant': {
type: 'nmtokens',
values: ['additions', 'all', 'removals', 'text'],
global: true
},
'aria-required': {
type: 'boolean'
},
'aria-roledescription': {
type: 'string',
allowEmpty: true,
global: true
},
'aria-rowcount': {
type: 'int'
},
'aria-rowindex': {
type: 'int'
},
'aria-rowspan': {
type: 'int'
},
'aria-selected': {
type: 'nmtoken',
values: ['false', 'true', 'undefined']
},
'aria-setsize': {
type: 'int'
},
'aria-sort': {
type: 'nmtoken',
values: ['ascending', 'descending', 'none', 'other']
},
'aria-valuemax': {
type: 'decimal'
},
'aria-valuemin': {
type: 'decimal'
},
'aria-valuenow': {
type: 'decimal'
},
'aria-valuetext': {
type: 'string'
}
};

export default ariaAttrs;
Loading