@@ -3,6 +3,8 @@ import debounce from 'lodash.debounce'
3
3
import merge from 'lodash.merge'
4
4
import { checkAndReport , draf , resetCache , resetLastNotification } from './utils'
5
5
6
+ let firstCheck = false
7
+
6
8
export default function install ( Vue , options ) {
7
9
// Browser only
8
10
if ( typeof window === 'undefined' ) return
@@ -42,7 +44,7 @@ export default function install (Vue, options) {
42
44
43
45
// vue-axe methods in Vue Instance
44
46
Vue . prototype . $axe = {
45
- run ( { clearConsole = options . clearConsoleOnUpdate , element = document } = { } ) {
47
+ run ( { clearConsole = options . clearConsoleOnUpdate , element } = { } ) {
46
48
this . clearConsole ( clearConsole )
47
49
draf ( ( ) => checkAndReport ( options , element ) )
48
50
} ,
@@ -55,7 +57,8 @@ export default function install (Vue, options) {
55
57
}
56
58
} ,
57
59
debounce : debounce ( function ( ) {
58
- this . run ( )
60
+ resetCache ( )
61
+ draf ( ( ) => checkAndReport ( options ) )
59
62
} , 1000 , { maxWait : 5000 } )
60
63
}
61
64
@@ -65,13 +68,13 @@ export default function install (Vue, options) {
65
68
// Rechecking when updating specific component
66
69
Vue . mixin ( {
67
70
updated ( ) {
68
- this . $axe . debounce ( )
71
+ if ( firstCheck ) return this . $axe . debounce ( )
72
+ firstCheck = true
73
+ setTimeout ( ( ) => this . $axe . debounce ( ) , options . delay )
69
74
} ,
70
75
// Used for change of route
71
76
beforeDestroy ( ) {
72
77
this . $axe . clearConsole ( true )
73
78
}
74
79
} )
75
-
76
- setTimeout ( ( ) => draf ( ( ) => checkAndReport ( options , document ) ) , options . delay )
77
80
}
0 commit comments