Skip to content

Instantly share code, notes, and snippets.

@Accudio
Last active May 31, 2022 16:21
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 Accudio/3449778ac239f716ddd162fdbce3f1c5 to your computer and use it in GitHub Desktop.
Save Accudio/3449778ac239f716ddd162fdbce3f1c5 to your computer and use it in GitHub Desktop.
"Check for WCAG 2.0 parsing compliance" by [Steve Faulkner](https://twitter.com/SteveFaulkner) with added support for Alpine and Vue attributes
javascript:(function(){var a,b,c,d,e,f,g=0;if(a=["tag seen","Stray end tag","Bad start tag","violates nesting rules","Duplicate ID","first occurrence of ID","Unclosed element","not allowed as child of element","unclosed elements","not allowed on element","unquoted attribute value","Duplicate attribute"].join("|"),b=document.getElementById("results"),!b)return void alert("No results container found.");for(c=b.getElementsByTagName("li"),f=0;f<c.length;f++)d=c[f],""!==d.className%26%26(e=(void 0===d.innerText%3Fd.textContent:d.innerText)+"",resultHtml=d.innerHTML,null===e.match(a)%3F(d.style.display="none",d.className+=" steveNoLike",g++):-1!==e.indexOf("not allowed on element")%26%26(-1!==resultHtml.indexOf("<code>ng-")||-1!==resultHtml.indexOf("<code>x-")||-1!==resultHtml.indexOf("<code>ax-")||-1!==resultHtml.indexOf("<code>v-")||-1!==resultHtml.indexOf("<code>:")||-1!==resultHtml.indexOf("<code>%40"))%26%26(d.style.display="none",d.className+=" steveNoLike",g++));alert("Complete. "+g+" items removed.")})();
(function () {
var removeFramework = true
var filterStrings = [
'tag seen',
'Stray end tag',
'Bad start tag',
'violates nesting rules',
'Duplicate ID',
'first occurrence of ID',
'Unclosed element',
'not allowed as child of element',
'unclosed elements',
'not allowed on element',
'unquoted attribute value',
'Duplicate attribute'
]
var filterRE,
root,
results,
result,
resultText,
i,
cnt = 0
filterRE = filterStrings.join('|')
root = document.getElementById('results')
if (!root) {
alert('No results container found.')
return
}
results = root.getElementsByTagName('li')
for (i = 0; i < results.length; i++) {
result = results[i]
if (result.className !== '') {
resultText =
(result.innerText !== undefined
? result.innerText
: result.textContent) + ''
resultHtml = result.innerHTML
if (resultText.match(filterRE) === null) {
result.style.display = 'none'
result.className = result.className + ' steveNoLike'
cnt++
} else if (removeFramework == true) {
if (resultText.indexOf('not allowed on element') !== -1) {
if (
resultHtml.indexOf('<code>ng-') !== -1 ||
resultHtml.indexOf('<code>x-') !== -1 ||
resultHtml.indexOf('<code>ax-') !== -1 ||
resultHtml.indexOf('<code>v-') !== -1 ||
resultHtml.indexOf('<code>:') !== -1 ||
resultHtml.indexOf('<code>@') !== -1
) {
result.style.display = 'none'
result.className = result.className + ' steveNoLike'
cnt++
}
}
}
}
}
alert('Complete. ' + cnt + ' items removed.')
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment