Skip to content

Commit d5a919b

Browse files
dan-jensencoliff
authored andcommitted
Fix TypeError when converting back to password
After the password input has been converted to text, there is no input matching type=password. However, the JS assumed there is which resuled in a TypeError due to a null result when it looked for the input. This fixes the problem by selecting by class instead.
1 parent ad1c027 commit d5a919b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

js/show-password-toggle.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
*/
66

77
var ShowPasswordToggle = document.querySelector("[type='password']");
8+
ShowPasswordToggle.classList.add("input-password");
9+
document.getElementById("toggle-password").classList.remove("d-none");
810
ShowPasswordToggle.onclick = function () {
9-
document.querySelector("[type='password']").classList.add("input-password");
10-
document.getElementById("toggle-password").classList.remove("d-none");
11-
12-
const passwordInput = document.querySelector("[type='password']");
13-
const togglePasswordButton = document.getElementById("toggle-password");
11+
var passwordInput = document.querySelector(".input-password");
12+
var togglePasswordButton = document.getElementById("toggle-password");
1413

1514
togglePasswordButton.addEventListener("click", togglePassword);
1615
function togglePassword() {

0 commit comments

Comments
 (0)