1
1
import axeCore from 'axe-core'
2
2
import debounce from 'lodash.debounce'
3
- import { OPTIONS_DEFAULT } from './constants '
3
+ import merge from 'lodash.merge '
4
4
import { checkAndReport , resetCache , resetLastNotification } from './utils'
5
5
6
6
export default function install ( Vue , options ) {
7
7
// Browser only
8
8
if ( typeof window === 'undefined' ) return
9
9
10
- options = {
10
+ const defaultOptions = {
11
11
clearConsoleOnUpdate : true ,
12
+ config : {
13
+ checks : [ {
14
+ id : 'color-contrast' ,
15
+ options : {
16
+ noScroll : true
17
+ }
18
+ } ]
19
+ } ,
12
20
runOptions : {
13
21
reporter : 'v2' ,
14
22
resultTypes : [ 'violations' ]
15
23
} ,
16
- ...options
24
+ style : {
25
+ head : 'padding:6px;font-size:20px;color:#333;font-weight:bold;' ,
26
+ boldCourier : 'font-weight:bold;font-family:Courier;' ,
27
+ moderate : 'padding:2px 4px;border-radius:5px;background-color:#FFBA52;color:#222;font-weight:normal;' ,
28
+ critical : 'padding:2px 4px;border-radius:5px;background-color:#AD0000;color:#fff;font-weight:normal;' ,
29
+ serious : 'padding:2px 4px;border-radius:5px;background-color:#333;color:#FFCE85;font-weight:normal;' ,
30
+ minor : 'padding:2px 4px;border-radius:5px;background-color:#333;color:#FFCE85;font-weight:normal;' ,
31
+ title : 'font-color:black;font-weight:bold;' ,
32
+ url : 'font-color:#4D4D4D;font-weight:normal;'
33
+ }
17
34
}
18
35
36
+ options = merge ( defaultOptions , options )
37
+
19
38
// Configure the format data
20
- axeCore . configure ( { ...OPTIONS_DEFAULT . config , ... options . config } )
39
+ axeCore . configure ( { ...options . config } )
21
40
22
41
// Rechecking when updating specific component
23
42
Vue . mixin ( {
@@ -39,10 +58,7 @@ export default function install (Vue, options) {
39
58
} ,
40
59
debounceAxe : debounce ( function ( ) {
41
60
this . clearAxeConsole ( )
42
-
43
- this . $nextTick ( ( ) => {
44
- checkAndReport ( options , this . $el )
45
- } )
61
+ this . $nextTick ( ( ) => checkAndReport ( options , this . $el ) )
46
62
} , 1000 , { maxWait : 5000 } )
47
63
}
48
64
} )
0 commit comments