If you use React, updating the value on every change is a very common pattern.
The apps I've worked on weren't full SPAs, so I just used plain HTML for the login form.
this.input.value = 'password';
This would be fine. However updating the attribute (the way React recommends it with controlled components) would be something like: <input type="text" value={this.state.value} onChange={this.handleChange} />
This would be vulnerable to the the CSS keylogger.https://reactjs.org/docs/uncontrolled-components.html#defaul...
You can use a form and grab the values on submission.
<form onSubmit={this.handleSubmission}>
<input type="password" name="password" />
</form>
this.handleSubmission = event => {
// access to event.target.password.value
}Basically, the value of the input is tied to a "state engine" that acts as a single source of truth and when the user types in the input you'll update the state so that the rest of the application can know what's going on in the form without accessing the DOM.
The state engine is a fancy word for a variable that has a special setter function so that the changes can be reflected globally.