Skip to content

Commit b5d90f7

Browse files
committed
chore: deep merge defaultOptions with options
1 parent aa6db60 commit b5d90f7

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "vue-axe",
33
"version": "1.1.0",
44
"description": "Dynamic accessibility analysis for Vue.js using axe-core",
5-
"main": "dist/vue-dark-mode.umd.js",
6-
"module": "dist/vue-dark-mode.esm.js",
7-
"unpkg": "dist/vue-dark-mode.min.js",
5+
"main": "dist/vue-axe.umd.js",
6+
"module": "dist/vue-axe.esm.js",
7+
"unpkg": "dist/vue-axe.min.js",
88
"scripts": {
99
"dev": "rollup --config rollup.config.dev.js --watch",
1010
"build": "npm run build:umd & npm run build:es & npm run build:unpkg",
@@ -52,6 +52,7 @@
5252
"eslint-plugin-standard": "^4.0.1",
5353
"eslint-plugin-vue": "^6.2.2",
5454
"lodash.debounce": "^4.0.8",
55+
"lodash.merge": "^4.6.2",
5556
"rollup": "^2.8.2",
5657
"rollup-plugin-eslint": "^7.0.0",
5758
"rollup-plugin-peer-deps-external": "^2.2.2",

src/index.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,42 @@
11
import axeCore from 'axe-core'
22
import debounce from 'lodash.debounce'
3-
import { OPTIONS_DEFAULT } from './constants'
3+
import merge from 'lodash.merge'
44
import { checkAndReport, resetCache, resetLastNotification } from './utils'
55

66
export default function install (Vue, options) {
77
// Browser only
88
if (typeof window === 'undefined') return
99

10-
options = {
10+
const defaultOptions = {
1111
clearConsoleOnUpdate: true,
12+
config: {
13+
checks: [{
14+
id: 'color-contrast',
15+
options: {
16+
noScroll: true
17+
}
18+
}]
19+
},
1220
runOptions: {
1321
reporter: 'v2',
1422
resultTypes: ['violations']
1523
},
16-
...options
24+
style: {
25+
head: 'padding:6px;font-size:20px;color:#333;font-weight:bold;',
26+
boldCourier: 'font-weight:bold;font-family:Courier;',
27+
moderate: 'padding:2px 4px;border-radius:5px;background-color:#FFBA52;color:#222;font-weight:normal;',
28+
critical: 'padding:2px 4px;border-radius:5px;background-color:#AD0000;color:#fff;font-weight:normal;',
29+
serious: 'padding:2px 4px;border-radius:5px;background-color:#333;color:#FFCE85;font-weight:normal;',
30+
minor: 'padding:2px 4px;border-radius:5px;background-color:#333;color:#FFCE85;font-weight:normal;',
31+
title: 'font-color:black;font-weight:bold;',
32+
url: 'font-color:#4D4D4D;font-weight:normal;'
33+
}
1734
}
1835

36+
options = merge(defaultOptions, options)
37+
1938
// Configure the format data
20-
axeCore.configure({ ...OPTIONS_DEFAULT.config, ...options.config })
39+
axeCore.configure({ ...options.config })
2140

2241
// Rechecking when updating specific component
2342
Vue.mixin({
@@ -39,10 +58,7 @@ export default function install (Vue, options) {
3958
},
4059
debounceAxe: debounce(function () {
4160
this.clearAxeConsole()
42-
43-
this.$nextTick(() => {
44-
checkAndReport(options, this.$el)
45-
})
61+
this.$nextTick(() => checkAndReport(options, this.$el))
4662
}, 1000, { maxWait: 5000 })
4763
}
4864
})

0 commit comments

Comments
 (0)