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)); }