From fb6476224ff0537e179705c2ae0895672a23a67b Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 29 Aug 2016 16:40:57 -0700 Subject: Add tolerance for failed form persisting --- ui/lib/persistent-form.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ui/lib/persistent-form.js') diff --git a/ui/lib/persistent-form.js b/ui/lib/persistent-form.js index 2fd7600a2..c2bf99360 100644 --- a/ui/lib/persistent-form.js +++ b/ui/lib/persistent-form.js @@ -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({}) } + -- cgit v1.2.3 From c15eef9425531c86a9016d1cbad9d32f4d12edcd Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 29 Aug 2016 17:34:29 -0700 Subject: Make element enumeration Edge compatible --- ui/lib/persistent-form.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'ui/lib/persistent-form.js') diff --git a/ui/lib/persistent-form.js b/ui/lib/persistent-form.js index c2bf99360..d4dc20b03 100644 --- a/ui/lib/persistent-form.js +++ b/ui/lib/persistent-form.js @@ -14,10 +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) => { + + for (var i = 0; i < fields.length; i++) { + const field = fields[i] const key = field.getAttribute('data-persistent-formid') const cached = store[key] if (cached !== undefined) { @@ -25,7 +24,7 @@ PersistentForm.prototype.componentDidMount = function () { } field.addEventListener(eventName, this.persistentFieldDidUpdate.bind(this)) - }) + } } PersistentForm.prototype.getPersistentStore = function () { @@ -53,12 +52,10 @@ PersistentForm.prototype.persistentFieldDidUpdate = function (event) { PersistentForm.prototype.componentWillUnmount = function () { const fields = document.querySelectorAll('[data-persistent-formid]') - if (!fields) { - return - } - fields.forEach((field) => { + for (var i = 0; i < fields.length; i++) { + const field = fields[i] field.removeEventListener(eventName, this.persistentFieldDidUpdate.bind(this)) - }) + } this.setPersistentStore({}) } -- cgit v1.2.3