Last active
April 27, 2018 18:46
-
-
Save AutoSponge/d0380557f32df83b1d78c0c82a82212d to your computer and use it in GitHub Desktop.
Watch mutations for accessibility issues.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function (w, c) { | |
var s, o = new MutationObserver(d(a), 1000) | |
if (typeof axe === 'undefined') { | |
s = w.createElement('script') | |
s.src = 'https://cdnjs.cloudflare.com/ajax/libs/axe-core/3.0.2/axe.min.js' | |
s.onload = function () { | |
o.observe(w.body, c) | |
} | |
w.body.appendChild(s) | |
} else { | |
o.observe(w.body, c) | |
} | |
function a () { | |
axe.run().then(function (r) { | |
if (r.violations.length) { | |
console.error('aXe') | |
console.dir(r.violations) | |
} | |
}) | |
} | |
function d (f, t) { | |
var i | |
return function () { | |
clearTimeout(i) | |
o.disconnect() | |
i = setTimeout(f, t) | |
} | |
} | |
})(document, { | |
attributes: !0, | |
subtree: !0 | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment