Skip to content

Commit

Permalink
Fixed a JavaScript error when clicking something else than a toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
KittyGiraudel committed Mar 10, 2016
1 parent f2a57fe commit acf178e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions a11y-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
var target = targetsMap[toggle.getAttribute('aria-controls')];
var isExpanded = JSON.parse(toggle.getAttribute('aria-expanded'));

toggle.setAttribute('aria-expanded', !isExpanded);
target.setAttribute('aria-hidden', isExpanded);
target && toggle.setAttribute('aria-expanded', !isExpanded);
target && target.setAttribute('aria-hidden', isExpanded);
});
}());
2 changes: 1 addition & 1 deletion a11y-toggle.min.js

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

4 changes: 2 additions & 2 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
var target = targetsMap[toggle.getAttribute('aria-controls')];
var isExpanded = JSON.parse(toggle.getAttribute('aria-expanded'));

toggle.setAttribute('aria-expanded', !isExpanded);
target.setAttribute('aria-hidden', isExpanded);
target && toggle.setAttribute('aria-expanded', !isExpanded);
target && target.setAttribute('aria-hidden', isExpanded);
});
}());

0 comments on commit acf178e

Please sign in to comment.