Skip to content

Commit b2b9a6d

Browse files
committed
debounce the axe running function to avoid it spamming itself
1 parent 8124163 commit b2b9a6d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axeCore from 'axe-core'
2+
import debounce from 'lodash.debounce'
23
import { checkAndReport, resetCache } from './utils'
34
import { OPTIONS_DEFAULT } from './constants'
45

@@ -13,15 +14,19 @@ export default function install (Vue, options) {
1314
Vue.mixin({
1415
methods: {
1516
clearAxeConsole () {
16-
console.clear()
1717
resetCache()
18-
}
18+
console.clear()
19+
},
20+
debounceAxe: debounce(function () {
21+
this.clearAxeConsole()
22+
23+
this.$nextTick(() => {
24+
checkAndReport(this.$el)
25+
})
26+
}, 2000, { maxWait: 6000 })
1927
},
2028
updated () {
21-
this.clearAxeConsole()
22-
this.$nextTick(() => {
23-
checkAndReport(this.$el)
24-
})
29+
this.debounceAxe()
2530
},
2631
// Used for change of route
2732
beforeDestroy () {

0 commit comments

Comments
 (0)