Skip to content

Instantly share code, notes, and snippets.

@AutoSponge
Last active April 27, 2018 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AutoSponge/d0380557f32df83b1d78c0c82a82212d to your computer and use it in GitHub Desktop.
Save AutoSponge/d0380557f32df83b1d78c0c82a82212d to your computer and use it in GitHub Desktop.
Watch mutations for accessibility issues.
;(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