diff --git a/a11y-toggle.js b/a11y-toggle.js index 5980713..dc94c04 100644 --- a/a11y-toggle.js +++ b/a11y-toggle.js @@ -58,10 +58,11 @@ var toggle = event.target.hasAttribute(namespace) ? event.target : closest(event.target, '[' + namespace + ']'); - var target = targetsMap[toggle.getAttribute(namespace)]; - var isExpanded = toggle.getAttribute('aria-expanded') === 'true'; + var target = toggle && targetsMap[toggle.getAttribute(namespace)]; if (target) { + var isExpanded = toggle.getAttribute('aria-expanded') === 'true'; + toggle.setAttribute('aria-expanded', !isExpanded); target.setAttribute('aria-hidden', isExpanded); } diff --git a/a11y-toggle.min.js b/a11y-toggle.min.js index 8247104..0f1dd94 100644 --- a/a11y-toggle.min.js +++ b/a11y-toggle.min.js @@ -1 +1 @@ -!function(){function t(t){if(Object.keys)return Object.keys(t);var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e}function e(t,e){for(var r=t.webkitMatchesSelector?"webkitMatchesSelector":t.msMatchesSelector?"msMatchesSelector":"matches";t.parentElement;){if(t[r](e))return t;t=t.parentElement}return null}for(var r="data-a11y-toggle",a=document.querySelectorAll("["+r+"]"),i={},n=0;n