aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/utils.js')
-rw-r--r--src/js/utils.js12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/js/utils.js b/src/js/utils.js
index c18fdfbc..84947e58 100644
--- a/src/js/utils.js
+++ b/src/js/utils.js
@@ -545,19 +545,17 @@ const utils = {
// Toggle aria-pressed state on a toggle button
// http://www.ssbbartgroup.com/blog/how-not-to-misuse-aria-states-properties-and-roles
- toggleState(target, state) {
+ toggleState(element, input) {
// Bail if no target
- if (!target) {
- return null;
+ if (!utils.is.htmlElement(element)) {
+ return;
}
// Get state
- const newState = utils.is.boolean(state) ? state : !target.getAttribute('aria-pressed');
+ const state = utils.is.boolean(input) ? input : !element.getAttribute('aria-pressed');
// Set the attribute on target
- target.setAttribute('aria-pressed', newState);
-
- return newState;
+ element.setAttribute('aria-pressed', state);
},
// Get percentage