1
1
import axeCore from 'axe-core'
2
- import debounce from 'lodash.debounce'
3
- import merge from 'lodash.merge'
2
+ import merge from 'deepmerge'
4
3
import { checkAndReport , resetCache } from './audit'
5
4
import { clear , defaultOptions , draf } from './utils'
6
5
7
- export default function install ( Vue , options ) {
6
+ export default function install ( Vue , options = { } ) {
8
7
// Browser only
9
8
if ( typeof window === 'undefined' ) return
10
9
@@ -29,16 +28,18 @@ export default function install (Vue, options) {
29
28
// if false, disable automatic verification
30
29
if ( ! options . auto ) return
31
30
32
- const checkWithDebounce = debounce ( function ( ) {
31
+ function axeRun ( ) {
33
32
const componentsName = this . $options . name || ''
34
33
resetCache ( )
35
34
draf ( ( ) => checkAndReport ( options , this . $el , componentsName ) )
36
- } , 1000 , { maxWait : 5000 } )
35
+ }
37
36
38
37
// Rechecking when updating specific component
38
+ let timeout = null
39
39
Vue . mixin ( {
40
40
updated ( ) {
41
- checkWithDebounce . call ( this )
41
+ timeout && clearTimeout ( timeout )
42
+ timeout = setTimeout ( axeRun . bind ( this ) , 2500 )
42
43
} ,
43
44
// Used for change of route
44
45
beforeDestroy ( ) {
0 commit comments