From 9acb4eb28cef6b3e18c9e16cfbe9e626ed7aec4a Mon Sep 17 00:00:00 2001 From: Philipp Matthias Schaefer Date: Sun, 14 Mar 2021 21:37:45 +0100 Subject: [PATCH] refactor(js): do not redundantly pass field name --- src/static/webldappasswd.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/static/webldappasswd.js b/src/static/webldappasswd.js index ab113a5..36d07af 100644 --- a/src/static/webldappasswd.js +++ b/src/static/webldappasswd.js @@ -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");