Skip to content

Commit 0d44740

Browse files
committed
only console when the violations have changed to the last report to avoid spamming
1 parent 5a9e765 commit 0d44740

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
let cache = {}
88
let nodes = []
99
let deferred = {}
10+
let lastNotification = ''
1011

1112
export function checkAndReport (node) {
1213
nodes.push(node)
@@ -15,6 +16,7 @@ export function checkAndReport (node) {
1516
axeCore.run(document, { reporter: 'v2' }, (error, results) => {
1617
if (error) deferred.reject(error)
1718
if (!results) return
19+
if (JSON.stringify(results.violations) === lastNotification) return
1820

1921
results.violations = results.violations.filter(result => {
2022
result.nodes = result.nodes.filter(node => {
@@ -40,6 +42,8 @@ export function checkAndReport (node) {
4042
console.groupEnd()
4143
}
4244
deferred.resolve()
45+
46+
lastNotification = JSON.stringify(results.violations)
4347
})
4448
return deferred.promise
4549
}

0 commit comments

Comments
 (0)