Skip to content

Commit

Permalink
Merge pull request #13 from Muhnad/Fix/stylesheet-condition
Browse files Browse the repository at this point in the history
Stylesheet condition
  • Loading branch information
Muhnad authored Jan 5, 2017
2 parents cd1b567 + e29a589 commit c4c68fb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
13 changes: 8 additions & 5 deletions a11y.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const a11yChecker = () =>
const a11yChecker = () => {
'use strict';

const getElement = (element) => document.getElementsByTagName(element)
Expand Down Expand Up @@ -50,6 +50,8 @@ const a11yChecker = () =>
const checkPrintStyle = (() => {
const link = getElement('link');
for (let i = 0; i < link.length; i++) {
const linkStylesheet = link[i].getAttribute('rel');
if (linkStylesheet === 'stylesheet') {
if (link[i].hasAttribute('media') >= 0) {
const linkMedia = link[i].getAttribute('media');
if (linkMedia !== 'print') {
Expand All @@ -59,6 +61,7 @@ const a11yChecker = () =>
console.warn('Should add print style file to document.');
}
}
}
})();

const checkHeading = (() => {
Expand Down Expand Up @@ -119,7 +122,7 @@ code: ${anchor[i].outerHTML}`)
if (anchor[i].hasAttribute('target')) {
const anchorTarget = anchor[i].getAttribute('target');
if (anchorTarget === '_blank') {
if (!anchor[i].hasAttribute('aria-describedby')) {
if (!anchor[i].hasAttribute('aria-describedby')) {
console.warn(`Should add alert to recognize this link will open in new tab.
code: ${anchor[i].outerHTML}`);
}
Expand All @@ -132,7 +135,7 @@ code:${anchor[i].outerHTML}`);
} else {
console.warn(`Should add rel=noopener to
code: ${anchor[i].outerHTML}`);
}
}
}
}
}
Expand Down Expand Up @@ -412,6 +415,6 @@ code: ${allElements[i].outerHTML}`)
}
}
}
})();

})();
}
window.addEventListener('load', a11yChecker);
46 changes: 23 additions & 23 deletions a11y.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
Expand Down

0 comments on commit c4c68fb

Please sign in to comment.