1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Add tolerance for failed form persisting

This commit is contained in:
Dan Finlay 2016-08-29 16:40:57 -07:00
parent e85418b11a
commit fb6476224f

View File

@ -14,6 +14,9 @@ inherits(PersistentForm, Component)
PersistentForm.prototype.componentDidMount = function () {
const fields = document.querySelectorAll('[data-persistent-formid]')
const store = this.getPersistentStore()
if (!fields) {
return
}
fields.forEach((field) => {
const key = field.getAttribute('data-persistent-formid')
const cached = store[key]
@ -50,8 +53,12 @@ PersistentForm.prototype.persistentFieldDidUpdate = function (event) {
PersistentForm.prototype.componentWillUnmount = function () {
const fields = document.querySelectorAll('[data-persistent-formid]')
if (!fields) {
return
}
fields.forEach((field) => {
field.removeEventListener(eventName, this.persistentFieldDidUpdate.bind(this))
})
this.setPersistentStore({})
}