Skip to content

Commit

Permalink
fix(plugin): fix issue with aria-hidden visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
ericrallen committed May 19, 2019
1 parent a7a728a commit 968f87b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
14 changes: 3 additions & 11 deletions package-lock.json

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

22 changes: 11 additions & 11 deletions plugins/aria-visualizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* Allows users to see what screen readers would see.
*/

let Plugin = require("../base");
const Plugin = require("../base");

let annotate = require("../shared/annotate")("roles");
const annotate = require("../shared/annotate")("roles");

// this will let us get a shorter info panel that just
// lets the user know we are tracking their focus
// lets the user know we are visualizing a Screen Reader View
const PANEL_OPTIONS = {
statusPanelView: true
};
Expand Down Expand Up @@ -42,27 +42,26 @@ class AriaVisualizer extends Plugin {
}

getTitle() {
return "aria-* Visualizer";
return "Screen Reader View";
}

getDescription() {
return "See the effects of your aria-* and other a11y attributes";
return "View the page as if you were a Screen Reader. See the effects of aria-* and other a11y attributes.";
}

startAriaHidden(attribute) {
const ariaName = `aria-${attribute}`;
const className = `tota11y-${attribute}-visualized`;

[...document.querySelectorAll(`[${ariaName}="true"]:not(.tota11y)`)].forEach((element) => {
[...document.querySelectorAll(`[${attribute}="true"]:not(.tota11y)`)].forEach((element) => {
// make sure we aren't visualizing our tota11y DOM
if (!element.closest(".tota11y")) {
element.classList.add(`tota11y-${ariaName}-visualized`);
element.classList.add(className);
}
});
}

stopAriaHidden(attribute) {
const ariaName = `aria-${attribute}`;

const className = `tota11y-${ariaName}-visualized`;
const className = `tota11y-${attribute}-visualized`;

[...document.querySelectorAll(`.${className}`)].forEach((element) => {
element.classList.remove(className);
Expand All @@ -71,6 +70,7 @@ class AriaVisualizer extends Plugin {

startRole(attribute) {
[...document.querySelectorAll(`[${attribute}]:not(.tota11y)`)].forEach((element) => {
// make sure we aren't annotating our tota11y DOM
if (!element.closest(".tota11y")) {
annotate.label(
element,
Expand Down
4 changes: 2 additions & 2 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ <h1>Hello, world!</h1>

<article id="article">
<p>This paragraph is visible.</p>
<p id="p-with-hidden">This paragraph has a <span id="span" aria-hidden="true">hidden</span> span.</p>
<p id="hidden-p" aria-hidden="true">This paragraph is hidden.</p>
<p id="p-with-hidden">This paragraph has an <span id="span" aria-hidden="true">aria-hidden</span> span.</p>
<p id="hidden-p" aria-hidden="true">This paragraph is aria-hidden.</p>
</article>

<p>
Expand Down

0 comments on commit 968f87b

Please sign in to comment.