Skip to content

Commit 0c59ff9

Browse files
committed
fix(checkAndReport): Using double requestAnimationFrame to checkAndReport
1 parent f097f3a commit 0c59ff9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/index.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import debounce from 'lodash.debounce'
33
import merge from 'lodash.merge'
44
import { checkAndReport, draf, resetCache, resetLastNotification } from './utils'
55

6+
let firstCheck = false
7+
68
export default function install (Vue, options) {
79
// Browser only
810
if (typeof window === 'undefined') return
@@ -42,7 +44,7 @@ export default function install (Vue, options) {
4244

4345
// vue-axe methods in Vue Instance
4446
Vue.prototype.$axe = {
45-
run ({ clearConsole = options.clearConsoleOnUpdate, element = document } = {}) {
47+
run ({ clearConsole = options.clearConsoleOnUpdate, element } = {}) {
4648
this.clearConsole(clearConsole)
4749
draf(() => checkAndReport(options, element))
4850
},
@@ -55,7 +57,8 @@ export default function install (Vue, options) {
5557
}
5658
},
5759
debounce: debounce(function () {
58-
this.run()
60+
resetCache()
61+
draf(() => checkAndReport(options))
5962
}, 1000, { maxWait: 5000 })
6063
}
6164

@@ -65,13 +68,13 @@ export default function install (Vue, options) {
6568
// Rechecking when updating specific component
6669
Vue.mixin({
6770
updated () {
68-
this.$axe.debounce()
71+
if (firstCheck) return this.$axe.debounce()
72+
firstCheck = true
73+
setTimeout(() => this.$axe.debounce(), options.delay)
6974
},
7075
// Used for change of route
7176
beforeDestroy () {
7277
this.$axe.clearConsole(true)
7378
}
7479
})
75-
76-
setTimeout(() => draf(() => checkAndReport(options, document)), options.delay)
7780
}

0 commit comments

Comments
 (0)