From ff3c249b6d9d346329da6d58e4ddced57547cdf3 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 18 Apr 2024 08:23:59 -0400 Subject: [PATCH] Remove elements from `pane.persist` that no longer persist anything --- chrome/content/zotero/zoteroPane.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index e4229f5ef3..52a8a91490 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -6074,7 +6074,7 @@ var ZoteroPane = new function() }; /** - * Serializes zotero-persist elements to preferences + * Serializes zotero-persist attributes to preferences */ this.serializePersist = function() { if (!_unserialized) return; @@ -6084,6 +6084,7 @@ var ZoteroPane = new function() catch (e) { serializedValues = {}; } + var persistedElements = new Set(); for (let el of document.querySelectorAll("[zotero-persist]")) { if (!el.getAttribute) continue; var id = el.getAttribute("id"); @@ -6092,10 +6093,17 @@ var ZoteroPane = new function() for (let attr of el.getAttribute("zotero-persist").split(/[\s,]+/)) { if (el.hasAttribute(attr)) { elValues[attr] = el.getAttribute(attr); + persistedElements.add(id); } } serializedValues[id] = elValues; } + // Remove elements that no longer persist anything + for (let i in serializedValues) { + if (!persistedElements.has(i)) { + delete serializedValues[i]; + } + } Zotero.Prefs.set("pane.persist", JSON.stringify(serializedValues)); }