Skip to content

Commit c6f03a7

Browse files
committed
fix: Console error in Nuxt app
1 parent 6b71d82 commit c6f03a7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/index.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import axeCore from 'axe-core'
2-
import debounce from 'lodash.debounce'
3-
import merge from 'lodash.merge'
2+
import merge from 'deepmerge'
43
import { checkAndReport, resetCache } from './audit'
54
import { clear, defaultOptions, draf } from './utils'
65

7-
export default function install (Vue, options) {
6+
export default function install (Vue, options = {}) {
87
// Browser only
98
if (typeof window === 'undefined') return
109

@@ -29,16 +28,18 @@ export default function install (Vue, options) {
2928
// if false, disable automatic verification
3029
if (!options.auto) return
3130

32-
const checkWithDebounce = debounce(function () {
31+
function axeRun () {
3332
const componentsName = this.$options.name || ''
3433
resetCache()
3534
draf(() => checkAndReport(options, this.$el, componentsName))
36-
}, 1000, { maxWait: 5000 })
35+
}
3736

3837
// Rechecking when updating specific component
38+
let timeout = null
3939
Vue.mixin({
4040
updated () {
41-
checkWithDebounce.call(this)
41+
timeout && clearTimeout(timeout)
42+
timeout = setTimeout(axeRun.bind(this), 2500)
4243
},
4344
// Used for change of route
4445
beforeDestroy () {

0 commit comments

Comments
 (0)