File tree Expand file tree Collapse file tree 4 files changed +24
-13
lines changed Expand file tree Collapse file tree 4 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ run in the background automatically. If there are any accessibility issues on
20
20
that page, accesslint.js will log the error to the console, and post to a server
21
21
endpoint that you can optionally configure.
22
22
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.
25
+
23
26
accesslint.js runs assertions from the
24
27
[ aXe-core] ( https://github.com/dequelabs/axe-core ) accessibility library wherever
25
28
you include the script. It the logs the violations the browser's Javascript
Original file line number Diff line number Diff line change 1
1
import { axe } from "axe-core/axe.min.js" ;
2
2
import report from "./reporter" ;
3
3
4
- export default function ( ) {
4
+ export default function ( target ) {
5
5
const options = {
6
6
"rules" : {
7
7
"color-contrast" : { enabled : false } ,
8
8
}
9
9
} ;
10
10
11
- window . axe . a11yCheck ( document , options , ( results ) => {
11
+ window . axe . a11yCheck ( target . parentNode , options , ( results ) => {
12
12
report ( results ) ;
13
13
} ) ;
14
14
}
Original file line number Diff line number Diff line change @@ -3,8 +3,22 @@ import auditor from "./auditor.js";
3
3
( function ( ) {
4
4
var load = function ( ) {
5
5
window . removeEventListener ( "load" , load , false ) ;
6
- auditor ( ) ;
6
+ auditor ( document ) ;
7
+ } ;
8
+
9
+ var observer = new MutationObserver ( function ( mutations ) {
10
+ mutations . forEach ( function ( mutation ) {
11
+ auditor ( mutation . target ) ;
12
+ } ) ;
13
+ } ) ;
14
+
15
+ var config = {
16
+ attributes : true ,
17
+ childList : true ,
18
+ characterData : true ,
19
+ subtree : true
7
20
} ;
8
21
9
22
window . addEventListener ( "load" , load ) ;
23
+ observer . observe ( document , config ) ;
10
24
} ) ( ) ;
Original file line number Diff line number Diff line change @@ -2,21 +2,15 @@ import request from "browser-request";
2
2
3
3
const url = "/access_lint/errors" ;
4
4
5
- export default function ( message ) {
5
+ export default function ( message ) {
6
6
var violations = message . violations . map ( function ( violation ) {
7
7
return {
8
8
description : violation . description ,
9
9
help : violation . help ,
10
- helpUrl : violation . helpUrl ,
11
- id : violation . id ,
12
10
impact : violation . impact ,
13
11
nodes : violation . nodes . map ( function ( n ) {
14
- return {
15
- target : n . target ,
16
- html : n . html
17
- } ;
12
+ return document . querySelectorAll ( n . target ) ;
18
13
} ) ,
19
- tags : violation . tags
20
14
} ;
21
15
} ) ;
22
16
@@ -31,7 +25,7 @@ export default function (message) {
31
25
}
32
26
}
33
27
} , function ( ) { } ) ;
34
- }
35
28
36
- console . log ( "AccessLint warnings: " , violations ) ;
29
+ console . warn ( violations ) ;
30
+ }
37
31
}
You can’t perform that action at this time.
0 commit comments