|
1 | 1 | import axeCore from 'axe-core'
|
2 |
| -import { IMPACT, STYLE } from './constants' |
3 | 2 |
|
4 | 3 | let cache = {}
|
| 4 | +let style = {} |
5 | 5 | const nodes = []
|
6 | 6 | const deferred = {}
|
7 | 7 | let lastNotification = ''
|
8 | 8 |
|
9 | 9 | export function checkAndReport (options, node) {
|
10 | 10 | nodes.push(node)
|
11 | 11 | const deferred = createDeferred()
|
| 12 | + style = { ...options.style } |
12 | 13 |
|
13 | 14 | axeCore.run(document, options.runOptions, (error, results) => {
|
14 | 15 | if (error) deferred.reject(error)
|
@@ -40,10 +41,10 @@ const standardResultHandler = function (errorInfo, results) {
|
40 | 41 | })
|
41 | 42 |
|
42 | 43 | if (results.violations.length) {
|
43 |
| - console.group('%cNew aXe issues', STYLE.head) |
| 44 | + console.group('%cNew axe issues', style.head) |
| 45 | + console.log(results.violations) |
44 | 46 | results.violations.forEach(result => {
|
45 |
| - const styl = IMPACT[result.impact] || IMPACT.minor |
46 |
| - console.groupCollapsed('%c%s: %c%s %s', STYLE[styl], result.impact, STYLE.defaultReset, result.help, result.helpUrl) |
| 47 | + console.groupCollapsed('%c%s%c %s %s %c%s', style[result.impact || 'minor'], result.impact, style.title, result.help, '\n', style.url, result.helpUrl) |
47 | 48 | result.nodes.forEach(function (node) {
|
48 | 49 | failureSummary(node, 'any')
|
49 | 50 | failureSummary(node, 'none')
|
@@ -97,14 +98,14 @@ function failureSummary (node, key) {
|
97 | 98 | function logElement (node, logFn) {
|
98 | 99 | var el = document.querySelector(node.target.toString())
|
99 | 100 | if (!el) {
|
100 |
| - logFn('Selector: %c%s', STYLE.boldCourier, node.target.toString()) |
| 101 | + logFn('Selector: %c%s', style.boldCourier, node.target.toString()) |
101 | 102 | } else {
|
102 | 103 | logFn('Element: %o', el)
|
103 | 104 | }
|
104 | 105 | }
|
105 | 106 |
|
106 | 107 | function logHtml (node) {
|
107 |
| - console.log('HTML: %c%s', STYLE.boldCourier, node.html) |
| 108 | + console.log('HTML: %c%s', style.boldCourier, node.html) |
108 | 109 | }
|
109 | 110 |
|
110 | 111 | function logFailureMessage (node, key) {
|
|
0 commit comments