Multiple #user_current_password on /settings/account

There are two DOM elements with the same id (#user_current_password) on the WK accounts page.

  • The password you enter when changing email address
  • The current password when changing password

image

I’m not sure if this would cause a problem when trying to change email address or password. I just happened to notice the error on the console while testing generating a new APIv2 key on that page.

It looks to be using HTML form submission, so the name would be the important part. Since both inputs have are in separate forms, there shouldn’t be any functional issues. I do agree that one or both ID attributes should be changed, since they’re supposed to be unique and all.

I was thinking the “account:1” on the right was suggesting a script was trying to do something with it, but it turns out that’s not the case. ‘account’ is the html file. And while it does have a tiny bit of javascript in that doc, it’s not accessing #user_current_password.

I did find it interesting, though, that

$('#user_current_password')

only returns the first instance, whereas

document.querySelectorAll('#user_current_password')

returns both. I wonder if that’s also true of newer versions of jquery.

The latest docs for jQuery say it uses getElementById with a pure id selector, and in the next paragraph says it will return a collection of either so or one element.

Strictly speaking, a document with more than one element with a given id is invalid, but browsers don’t complain because HTML is so robust.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.