⬆️ ⬇️

Polyfill to work around browser forms autocomplete

A year ago, issue # 1460 "Form model does not update on autocomplete" was created in the AngularJS repository.



The browser, when filling out a form with previously saved data (for example, entering email - the browser fills in the password automatically) does not notify the javascript about new data in the field.



During the existence of this problem, various crutches were written, which can be assessed in the comments to the issue. Now the official crutch appeared. And while browser developers are not paying attention to the problem, this is the optimal solution - Autofill event polyfill .



We'll have to connect another script. The principle of operation is as follows: according to “DOMContentLoaded”, the script runs through the fields and remembers their current value, after a timeout of 200 milliseconds compares the previously saved value with the current one, if they differ - the “change” event is triggered for the field. On the event "blur" for one of the fields, the scan is run again.

')

References:

Autofill event polyfill

issue # 1460

Source: https://habr.com/ru/post/211863/



All Articles