Skip to content

Commit 3ee87b7

Browse files
author
Cameron Cundiff
committed
Remove server reporting, fixes for poltergeist
- Do not POST to /access_lint/errors. This should be a configuration option eventually. - Log violation message in a format that poltergeist webdriver can handle. - Check deep equality of the violation messages with underscore (JSON.stringify was failing in poltergeist). - Update Readme.
1 parent 93d8f3c commit 3ee87b7

File tree

5 files changed

+23
-55
lines changed

5 files changed

+23
-55
lines changed

README.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,27 @@ accesslint.js warns you of accessibility errors in your website.
66

77
## Usage
88

9-
Download the [latest release](https://github.com/accesslint/accesslint.js/releases/latest) and
10-
include the javascript in your page:
9+
Download the
10+
[latest release](https://github.com/accesslint/accesslint.js/releases/latest)
11+
and include the javascript in your page at the end of the `<body>` tag.
1112

1213
```
1314
<script src="accesslint.js" type="text/javascript">
1415
```
1516

16-
## How it works
17-
18-
When a visitor arrives at a page that has the script installed, an audit will
19-
run in the background automatically. If there are any accessibility issues on
20-
that page, accesslint.js will log the error to the console, and post to a server
21-
endpoint that you can optionally configure.
17+
Open the page and watch your browser's JavaScript console for warnings.
2218

23-
The audit will run once on page load, and **again for each DOM change event.**
24-
This feature gives you feedback on new content introduced via AJAX, for example.
19+
## How it works
2520

2621
accesslint.js runs assertions from the
2722
[aXe-core](https://github.com/dequelabs/axe-core) accessibility library wherever
28-
you include the script. It the logs the violations the browser's Javascript
29-
console. It also POSTs the results to `/access_lint/errors` in your app. If you
30-
set up and endpoint with that path, you can log the errors on the server too.
31-
See [AccessLint::Rails](https://github.com/thoughtbot/access_lint-rails) for a
32-
Rails implementation of server side logging of accessibility errors.
33-
34-
![animated screencapture of accesslint warnings to the console](https://cloud.githubusercontent.com/assets/108163/15450990/693ce7e4-1f7c-11e6-8778-6a6aced77679.gif)
23+
you include the script once on page load, and again for each DOM change event.
3524

25+
This feature gives you feedback on new content introduced via AJAX, for example,
26+
or updates to a single page app.
3627

3728
## Development
3829

39-
AccessLint Monitor uses babel and webpack to transpile and package ES2015
40-
code for inclusion clientside. It uses karma and mocha to run tests.
41-
4230
### Setup
4331

4432
$ bin/setup

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"request": "~2.61.0",
4242
"sinon": "git://github.com/cjohansen/Sinon.JS#b672042043517b9f84e14ed0fb8265126168778a",
4343
"sinon-chai": "^2.8.0",
44+
"underscore": "^1.8.3",
4445
"webpack": "^1.12.9"
4546
},
4647
"dependencies": {

src/logger.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1+
import _ from "underscore";
2+
13
export default class Logger {
24
constructor() {
35
this.logged = []
46
}
57

68
warn(violation) {
7-
if(!this.exists(violation)) {
8-
console.warn(violation);
9+
if(!this.seen(violation)) {
10+
window.console.warn(violation.help, violation.nodes);
911
this.logged.push(violation);
1012
}
1113
}
1214

13-
exists(violation) {
14-
let exists = false;
15-
16-
this.logged.forEach(function(entry) {
17-
if (JSON.stringify(entry) === JSON.stringify(violation)) {
18-
exists = true;
19-
}
15+
seen(violation) {
16+
return _.any(this.logged, function(message) {
17+
return _.isEqual(message, violation)
2018
});
21-
22-
return exists;
2319
}
2420
}

src/reporter.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import request from "browser-request";
2-
3-
const url = "/access_lint/errors";
4-
51
export default function(message, logger) {
6-
72
var violations = message.violations.map(function(violation) {
83
return {
94
description: violation.description,
@@ -15,20 +10,7 @@ export default function(message, logger) {
1510
};
1611
});
1712

18-
if (violations.length > 0) {
19-
request({
20-
method: "POST",
21-
url: url,
22-
json: {
23-
accesslint: {
24-
violations: violations,
25-
url: window.location.pathname
26-
}
27-
}
28-
}, function() {});
29-
30-
violations.forEach(function(violation) {
31-
logger.warn(violation);
32-
});
33-
}
13+
violations.forEach(function(violation) {
14+
logger.warn(violation);
15+
});
3416
}

test/unit/logger_test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ describe("warn", () => {
1010
it("logs to console.warn", () => {
1111
let logger = new Logger();
1212
sinon.spy(console, "warn");
13-
logger.warn("example");
14-
logger.warn("example");
1513

16-
expect(console.warn).to.be.have.been.calledWith("example");
14+
logger.warn({ help: "example", nodes: []});
15+
logger.warn({ help: "example", nodes: []});
16+
17+
expect(console.warn).to.be.have.been.calledWith("example", []);
1718
expect(console.warn).to.be.have.been.calledOnce;
1819
});
1920
});

0 commit comments

Comments
 (0)