Skip to content

Commit 4cf7f0a

Browse files
committed
chore: Adding $axe in Vue instance
1 parent 6c4237f commit 4cf7f0a

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/index.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,33 @@ export default function install (Vue, options) {
3636

3737
options = merge(defaultOptions, options)
3838

39-
// Configure the format data
4039
axeCore.configure({ ...options.config })
4140

42-
// Rechecking when updating specific component
41+
Vue.prototype.$axe = {
42+
run ({ clearConsole = true, element = document } = {}) {
43+
this.clearConsole(clearConsole)
44+
if (!clearConsole) resetLastNotification()
45+
Vue.nextTick().then(() => checkAndReport(options, element))
46+
},
47+
clearConsole (forceClear = false) {
48+
resetCache()
49+
50+
if (forceClear || options.clearConsoleOnUpdate) {
51+
console.clear()
52+
resetLastNotification()
53+
}
54+
},
55+
debounce: debounce(function () {
56+
this.run({ clearConsole: options.clearConsoleOnUpdate })
57+
}, 1000, { maxWait: 5000 })
58+
}
59+
4360
Vue.mixin({
4461
updated () {
45-
this.debounceAxe()
62+
this.$axe.debounce()
4663
},
4764
beforeDestroy () {
48-
this.clearAxeConsole(true)
49-
},
50-
methods: {
51-
clearAxeConsole (forceClear = false) {
52-
resetCache()
53-
54-
if (forceClear || options.clearConsoleOnUpdate) {
55-
console.clear()
56-
resetLastNotification()
57-
}
58-
},
59-
axeRun ({ clearConsole = false, element = document } = {}) {
60-
this.clearAxeConsole(clearConsole)
61-
this.$nextTick(() => checkAndReport(options, element))
62-
},
63-
debounceAxe: debounce(function () {
64-
this.axeRun()
65-
}, 1000, { maxWait: 5000 })
65+
this.$axe.clearConsole(true)
6666
}
6767
})
6868

0 commit comments

Comments
 (0)