refactor(js): do not redundantly pass field name

This commit is contained in:
Philipp Matthias Schaefer 2021-03-14 21:37:45 +01:00
parent adb2cdfc41
commit 9acb4eb28c

View File

@ -70,8 +70,7 @@ FIELDS = ['username', 'old_password', 'new_password']
function mapFields(thunk) {
for (fieldIndex in FIELDS) {
const fieldName = FIELDS[fieldIndex]
const field = document.querySelectorAll(`input[name=${fieldName}]`)[0];
thunk(field, fieldName);
thunk(document.querySelector(`input[name=${fieldName}]`))
}
}
@ -84,8 +83,8 @@ function clearFields() {
function changePasswords() {
const query = {};
mapFields((field, fieldName) => {
query[fieldName] = field.value;
mapFields(field => {
query[field.name] = field.value;
});
showModal("Wait");