Skip to content

Commit

Permalink
Added aria-pressed attribute to button
Browse files Browse the repository at this point in the history
Solves issue coliff#24
  • Loading branch information
slackero committed Oct 30, 2021
1 parent f974e4d commit dd9cb61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions js/show-password-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ if (ShowPasswordTogglesLength) {
togglePasswordButton.type = 'button';
togglePasswordButton.classList.add('toggle-password');
togglePasswordButton.setAttribute('aria-label', togglePasswordButtonLabels.show);
togglePasswordButton.setAttribute('aria-pressed', 'false');
togglePasswordButton.addEventListener('click', function() {
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
togglePasswordButton.classList.add('password-visible');
togglePasswordButton.setAttribute('aria-label', togglePasswordButtonLabels.hide);
togglePasswordButton.setAttribute('aria-pressed', 'true');
} else {
passwordInput.type = 'password';
togglePasswordButton.classList.remove('password-visible');
togglePasswordButton.setAttribute('aria-label', togglePasswordButtonLabels.show);
togglePasswordButton.setAttribute('aria-pressed', 'false');
}
});
passwordInput.after(togglePasswordButton);
Expand Down
2 changes: 1 addition & 1 deletion js/show-password-toggle.min.js

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

0 comments on commit dd9cb61

Please sign in to comment.