Skip to content

Commit 88d039f

Browse files
committed
fix: Remove axe.a11yCheck()
BREAKING CHANGE
1 parent 9c7b9f1 commit 88d039f

File tree

12 files changed

+47
-179
lines changed

12 files changed

+47
-179
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ Installing aXe to run accessibility tests in your TypeScript project should be a
136136
import * as axe from 'axe-core';
137137

138138
describe('Module', () => {
139-
it('should have no accessibility violations', () => {
140-
axe.a11yCheck(compiledFixture, {}, (results) => {
141-
expect(results.violations.length).toBe(0);
142-
});
139+
it('should have no accessibility violations', (done) => {
140+
axe.run(compiledFixture)
141+
.then((results) => {
142+
expect(results.violations.length).toBe(0);
143+
done()
144+
}, done);
143145
});
144146
});
145147
```

axe.d.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,6 @@ declare module axe {
139139
function run(context: ElementContext, options: RunOptions): Promise<AxeResults>
140140
function run(context: ElementContext, options: RunOptions, callback: RunCallback): void
141141

142-
/**
143-
* Starts analysis on the current document and its subframes
144-
*
145-
* @param {Object} context The `Context` specification object @see Context
146-
* @param {Array} options Options passed into rules or checks, temporarily modifyint them.
147-
* @param {Function} callback The function to invoke when analysis is complete.
148-
* @returns {Object} results The aXe results object
149-
*/
150-
function a11yCheck(context: ElementContext, options: {runOnly?: RunOnly, rules?: Object, iframes?: Boolean, elementRef?: Boolean, selectors?: Boolean}, callback: (results:AxeResults) => void): AxeResults
151-
152142
/**
153143
* Method for configuring the data format used by aXe. Helpful for adding new
154144
* rules, which must be registered with the library to execute.

doc/API.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
1. [Results Object](#results-object)
2121
1. [API Name: axe.registerPlugin](#api-name-axeregisterplugin)
2222
1. [API Name: axe.cleanup](#api-name-axecleanup)
23-
1. [API Name: axe.a11yCheck](#api-name-axea11ycheck)
2423
1. [Virtual DOM Utilities](#virtual-dom-utilities)
2524
1. [API Name: axe.utils.querySelectorAll](#api-name-axeutilsqueryselectorall)
2625
1. [Common Functions](#common-functions)
@@ -619,14 +618,6 @@ Register a plugin with the aXe plugin system. See [implementing a plugin](plugin
619618

620619
Call the plugin system's cleanup function. See [implementing a plugin](plugins.md).
621620

622-
### API Name: axe.a11yCheck
623-
624-
In axe-core v1 the main method for axe was `axe.a11yCheck()`. This method was replaced with `axe.run()` in order to better deal with errors. The method `axe.a11yCheck()` differs from `axe.run()` in the following ways:
625-
626-
- .a11yCheck does not pass the error object to the callback, rather it returns the result as the first parameter and logs errors to the console.
627-
- .a11yCheck requires a context object, and so will not fall back to the document root.
628-
- .a11yCheck does not return a Promise.
629-
630621
### Virtual DOM Utilities
631622

632623
Note: If you’re writing rules or checks, you’ll have both the `node` and `virtualNode` passed in.

lib/core/public/a11y-check.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

test/core/public/a11y-check.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

test/core/public/run-rules.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ describe('runRules', function () {
491491

492492
fixture.innerHTML = '<div></div>';
493493

494-
axe.a11yCheck('#fixture', function (results) {
494+
axe.run('#fixture', function (err, results) {
495+
assert.isNull(err);
495496
assert.lengthOf(results.incomplete, 2);
496497
assert.equal(results.incomplete[0].id, 'incomplete-1');
497498
assert.equal(results.incomplete[1].id, 'incomplete-2');
@@ -527,15 +528,16 @@ describe('runRules', function () {
527528
});
528529

529530
iframeReady('../mock/frames/rule-error.html', fixture, 'context-test', function () {
530-
axe.a11yCheck('#fixture', function (results) {
531+
axe.run('#fixture', function (err, results) {
532+
assert.isNull(err);
531533
assert.lengthOf(results.incomplete, 2);
532534
assert.equal(results.incomplete[0].id, 'incomplete-1');
533535
assert.equal(results.incomplete[1].id, 'incomplete-2');
534536

535537
assert.include(results.incomplete[1].description,
536538
'An error occured while running this rule');
537539
done();
538-
}, isNotCalled);
540+
});
539541
});
540542
});
541543

test/integration/full/jquery/a11ycheck-include-exclude.html renamed to test/integration/full/jquery/run-include-exclude.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</div>
3131
<div id="mocha"></div>
3232
<script src="/node_modules/jquery/dist/jquery.js"></script>
33-
<script src="a11ycheck-include-exclude.js"></script>
33+
<script src="run-include-exclude.js"></script>
3434
<script src="/test/integration/adapter.js"></script>
3535
</body>
3636
</html>

test/integration/full/jquery/a11ycheck-include-exclude.js renamed to test/integration/full/jquery/run-include-exclude.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
/*global $ */
22

3-
describe('jQuery object with a11yCheck', function () {
3+
describe('jQuery object with axe.run', function () {
44
'use strict';
55

66
var config = { runOnly: { type: 'rule', values: ['aria-roles'] } };
77

88
describe('include', function() {
99
it('should find violations', function (done) {
1010
var target = $('#target')[0];
11-
axe.a11yCheck({ include: [target] }, config, function (results) {
11+
axe.run({ include: [target] }, config, function (err, results) {
12+
assert.isNull(err);
1213
assert.lengthOf(results.violations, 1, 'violations');
1314
assert.lengthOf(results.passes, 0, 'passes');
1415
done();
@@ -19,7 +20,8 @@ describe('jQuery object with a11yCheck', function () {
1920
describe('exclude', function() {
2021
it('should find no violations', function (done) {
2122
var target = $('#target')[0];
22-
axe.a11yCheck({ exclude: [target] }, config, function (results) {
23+
axe.run({ exclude: [target] }, config, function (err, results) {
24+
assert.isNull(err);
2325
assert.lengthOf(results.violations, 0, 'violations');
2426
assert.lengthOf(results.passes, 0, 'passes');
2527
done();

test/integration/full/jquery/a11ycheck-object.html renamed to test/integration/full/jquery/run-object.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</div>
3131
<div id="mocha"></div>
3232
<script src="/node_modules/jquery/dist/jquery.js"></script>
33-
<script src="a11ycheck-object.js"></script>
33+
<script src="run-object.js"></script>
3434
<script src="/test/integration/adapter.js"></script>
3535
</body>
3636
</html>

test/integration/full/jquery/a11ycheck-object.js renamed to test/integration/full/jquery/run-object.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*global $ */
22

3-
describe('jQuery object as a11yCheck context', function () {
3+
describe('jQuery object as axe.run context', function () {
44
'use strict';
55
var config = { runOnly: { type: 'rule', values: ['aria-roles'] } };
66
it('should find no violations', function (done) {
77
var fixture = $('#fixture');
8-
axe.a11yCheck(fixture, config, function (results) {
8+
axe.run(fixture, config, function (err, results) {
9+
assert.isNull(err);
910
assert.lengthOf(results.violations, 0, 'violations');
1011
assert.lengthOf(results.passes, 1, 'passes');
1112
done();

test/integration/full/options-parameter/options-parameter.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Options parameter', function() {
1919
describe('iframes', function() {
2020
it('should include iframes if `iframes` is true', function(done) {
2121
var config = { iframes: true };
22-
axe.a11yCheck(document, config, function(results) {
22+
axe.run(document, config, function(err, results) {
2323
try {
2424
assert.lengthOf(results.violations, 0, 'violations');
2525
assert.lengthOf(results.passes, 1, 'passes');
@@ -39,7 +39,7 @@ describe('Options parameter', function() {
3939

4040
it('should exclude iframes if `iframes` is false', function(done) {
4141
var config = { iframes: false };
42-
axe.a11yCheck(document, config, function(results) {
42+
axe.run(document, config, function(err, results) {
4343
try {
4444
assert.lengthOf(results.violations, 0, 'violations');
4545
assert.lengthOf(results.passes, 1, 'passes');
@@ -59,7 +59,7 @@ describe('Options parameter', function() {
5959

6060
it('should include iframes by default', function(done) {
6161
var config = {};
62-
axe.a11yCheck(document, config, function(results) {
62+
axe.run(document, config, function(err, results) {
6363
try {
6464
assert.lengthOf(results.violations, 0, 'violations');
6565
assert.lengthOf(results.passes, 1, 'passes');
@@ -81,7 +81,7 @@ describe('Options parameter', function() {
8181
describe('elementRef', function() {
8282
it('should not return an elementRef by default', function(done) {
8383
var config = {};
84-
axe.a11yCheck(document, config, function(results) {
84+
axe.run(document, config, function(err, results) {
8585
try {
8686
assert.lengthOf(results.violations, 0, 'violations');
8787
assert.lengthOf(results.passes, 1, 'passes');
@@ -98,7 +98,7 @@ describe('Options parameter', function() {
9898

9999
it('should not return an elementRef if `elementRef` is false', function(done) {
100100
var config = { elementRef: false };
101-
axe.a11yCheck(document, config, function(results) {
101+
axe.run(document, config, function(err, results) {
102102
try {
103103
assert.lengthOf(results.violations, 0, 'violations');
104104
assert.lengthOf(results.passes, 1, 'passes');
@@ -115,7 +115,7 @@ describe('Options parameter', function() {
115115

116116
it('should return element refs for the top frame only if `elementRef` is true', function(done) {
117117
var config = { elementRef: true };
118-
axe.a11yCheck(document, config, function(results) {
118+
axe.run(document, config, function(err, results) {
119119
try {
120120
assert.lengthOf(results.violations, 0, 'violations');
121121
assert.lengthOf(results.passes, 1, 'passes');
@@ -137,7 +137,7 @@ describe('Options parameter', function() {
137137
describe('no selectors', function() {
138138
it('should return a selector by default', function(done) {
139139
var config = {};
140-
axe.a11yCheck(document, config, function(results) {
140+
axe.run(document, config, function(err, results) {
141141
try {
142142
assert.lengthOf(results.violations, 0, 'violations');
143143
assert.lengthOf(results.passes, 1, 'passes');
@@ -154,7 +154,7 @@ describe('Options parameter', function() {
154154

155155
it('should return a selector if `selectors` is true', function(done) {
156156
var config = { selectors: true };
157-
axe.a11yCheck(document, config, function(results) {
157+
axe.run(document, config, function(err, results) {
158158
try {
159159
assert.lengthOf(results.violations, 0, 'violations');
160160
assert.lengthOf(results.passes, 1, 'passes');
@@ -171,7 +171,7 @@ describe('Options parameter', function() {
171171

172172
it('should return no selector in top frame if `selectors` is false', function(done) {
173173
var config = { selectors: false };
174-
axe.a11yCheck(document, config, function(results) {
174+
axe.run(document, config, function(err, results) {
175175
try {
176176
assert.lengthOf(results.violations, 0, 'violations');
177177
assert.lengthOf(results.passes, 1, 'passes');

0 commit comments

Comments
 (0)