Skip to content

Commit 2b83e9e

Browse files
committed
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 49a5acd commit 2b83e9e

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
@@ -1,10 +1,9 @@
11
var ShowPasswordToggle = document.querySelector("[type='password']");
2+
ShowPasswordToggle.classList.add("input-password");
3+
document.getElementById("toggle-password").classList.remove("d-none");
24
ShowPasswordToggle.onclick = function () {
3-
document.querySelector("[type='password']").classList.add("input-password");
4-
document.getElementById("toggle-password").classList.remove("d-none");
5-
6-
const passwordInput = document.querySelector("[type='password']");
7-
const togglePasswordButton = document.getElementById("toggle-password");
5+
var passwordInput = document.querySelector(".input-password");
6+
var togglePasswordButton = document.getElementById("toggle-password");
87

98
togglePasswordButton.addEventListener("click", togglePassword);
109
function togglePassword() {

0 commit comments

Comments
 (0)