Skip to content

Commit fb21d52

Browse files
committed
feat: Adding option to register and execute plugins
1 parent a9e0323 commit fb21d52

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: index.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface VueAxe
99
{
1010
run({ clearConsole, element }: RunOptions): void;
1111

12+
plugins: Record<object>;
13+
1214
clearConsole(forceClear: boolean): void;
1315

1416
debounce(): void;

Diff for: src/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,25 @@ export default function install (Vue, options) {
2828
minor: 'padding:2px 4px;border-radius:5px;background-color:#333;color:#FFCE85;font-weight:normal;',
2929
title: 'font-color:black;font-weight:bold;',
3030
url: 'font-color:#4D4D4D;font-weight:normal;'
31-
}
31+
},
32+
plugins: []
3233
}
3334

3435
options = merge(defaultOptions, options)
3536

3637
axeCore.configure({ ...options.config })
3738

39+
// register plugins
40+
options.plugins.forEach(plugin => axeCore.registerPlugin(plugin))
41+
42+
// vue-axe methods in Vue Instance
3843
Vue.prototype.$axe = {
3944
run ({ clearConsole = true, element = document } = {}) {
4045
this.clearConsole(clearConsole)
4146
if (!clearConsole) resetLastNotification()
4247
Vue.nextTick().then(() => checkAndReport(options, element))
4348
},
49+
plugins: axeCore.plugins,
4450
clearConsole (forceClear = false) {
4551
resetCache()
4652

@@ -54,10 +60,12 @@ export default function install (Vue, options) {
5460
}, 1000, { maxWait: 5000 })
5561
}
5662

63+
// Rechecking when updating specific component
5764
Vue.mixin({
5865
updated () {
5966
this.$axe.debounce()
6067
},
68+
// Used for change of route
6169
beforeDestroy () {
6270
this.$axe.clearConsole(true)
6371
}

0 commit comments

Comments
 (0)