From 20e7b492eaa81c42502ab139628cb2e2c75c219e Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Wed, 15 Mar 2023 10:44:56 +0100 Subject: [PATCH] FIX: use const instead of let for observedCache --- assets/javascripts/discourse/mixins/undo-changes.js.es6 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/discourse/mixins/undo-changes.js.es6 b/assets/javascripts/discourse/mixins/undo-changes.js.es6 index ce126bdd..e98cfb0e 100644 --- a/assets/javascripts/discourse/mixins/undo-changes.js.es6 +++ b/assets/javascripts/discourse/mixins/undo-changes.js.es6 @@ -4,7 +4,7 @@ import { get, set } from "@ember/object"; import Mixin from "@ember/object/mixin"; import { deepEqual } from "discourse-common/lib/object"; -let observedCache = []; +const observedCache = []; export default Mixin.create({ didInsertElement() { @@ -36,7 +36,10 @@ export default Mixin.create({ listProperties(componentType, opts).forEach((property) => { if (observedCache.includes(property)) { obj.removeObserver(property, this, this.toggleUndo); - observedCache = observedCache.filter((p) => p !== property); + let index = observedCache.indexOf(property); + if (index !== -1) { + observedCache.splice(index, 1); + } } }); },