Skip to content

Commit efc99e1

Browse files
committed
feat: Added "auto" option to manage automatic axe verification.
1 parent 0182083 commit efc99e1

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ if (process.env.NODE_ENV !== 'production') {
2626
## Configuration
2727
| Key | Type | Description | Default
2828
| ---------------------- | -------- |-------------------------------------------------------------- | -----------
29+
| `auto` | Boolean | Disables automatic verification. Only checks with `$axe.run` | `true`
2930
| `clearConsoleOnUpdate` | Boolean | Clears the console each time `vue-axe` runs | `false`
3031
| `customResultHandler` | Function | Handle the results. (This may be needed for automated tests)
3132
| `config` | Object | Provide your [Axe-core configuration](https://github.com/dequelabs/axe-core/blob/master/doc/API.md#api-name-axeconfigure) | [See default config](https://github.com/vue-a11y/vue-axe/blob/master/src/index.js#L13)

demo/src/main.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import Vue from 'vue'
2-
import VueAxe from 'vue-axe'
2+
import VueAxe from '../vue-axe'
33
import App from './App.vue'
44
import router from './router.js'
55

66
// Don't use this plugin in production => if (process.env.NODE_ENV !== 'production')
7-
Vue.use(VueAxe, {
8-
clearConsoleOnUpdate: true
9-
})
7+
Vue.use(VueAxe)
108
Vue.config.productionTip = false
119

1210
/* eslint-disable no-new */

demo/src/pages/Home.vue

+7-18
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
@click="showAlt = !showAlt"
3838
v-text="showAlt ? 'Remove the alt tag from the logo' : 'Add an alt tag to the logo'"
3939
/>
40-
<button @click="correctedLinkColor = !correctedLinkColor">
40+
<button @click="toggleLinkColor">
4141
Change links color
4242
</button>
4343

@@ -99,29 +99,18 @@ export default {
9999
},
100100
data () {
101101
return {
102-
// num: 0,
103102
correctedLinkColor: false,
104103
showAlt: false,
105104
scope: true
106105
}
107106
},
108-
// mounted()
109-
// {
110-
// this.updateNumber();
111-
// },
112-
// mounted () {
113-
// setTimeout(() => {
114-
// this.$axe.run({ clearConsole: false })
115-
// }, 5000)
116-
// },
117107
methods: {
118-
// updateNumber()
119-
// {
120-
// setTimeout(() => {
121-
// this.num += 1;
122-
// this.updateNumber();
123-
// }, 500);
124-
// }
108+
toggleLinkColor () {
109+
this.correctedLinkColor = !this.correctedLinkColor
110+
111+
// Using "auto: false" $axe.run working
112+
// this.$axe.run()
113+
}
125114
}
126115
}
127116
</script>

src/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function install (Vue, options) {
88
if (typeof window === 'undefined') return
99

1010
const defaultOptions = {
11+
auto: true,
1112
clearConsoleOnUpdate: false,
1213
delay: 0,
1314
config: {
@@ -60,6 +61,9 @@ export default function install (Vue, options) {
6061
}, 1000, { maxWait: 5000 })
6162
}
6263

64+
// if false, disable automatic verification
65+
if (!options.auto) return
66+
6367
// Rechecking when updating specific component
6468
Vue.mixin({
6569
updated () {

0 commit comments

Comments
 (0)