From ee6b9d7af7e1edb9e9519f3b50c57f74284afbd3 Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Mon, 1 Apr 2024 11:35:36 +0800 Subject: [PATCH] Refactor ItemPaneSection#_handleDataChange Remove unused _handleDataChange and rename it to _handleItemChange --- .../zotero/elements/itemPaneSection.js | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero/elements/itemPaneSection.js b/chrome/content/zotero/elements/itemPaneSection.js index 4876284d5a..74270214e5 100644 --- a/chrome/content/zotero/elements/itemPaneSection.js +++ b/chrome/content/zotero/elements/itemPaneSection.js @@ -30,9 +30,8 @@ class ItemPaneSectionElementBase extends XULElementBase { } set item(item) { - let success = this._handleDataChange("item", this._item, item); - if (success === false) return; this._item = item; + if (this._handleItemChange) this._handleItemChange(); } get editable() { @@ -49,9 +48,8 @@ class ItemPaneSectionElementBase extends XULElementBase { } set tabType(tabType) { - let success = this._handleDataChange("tabType", this._tabType, tabType); - if (success === false) return; this._tabType = tabType; + this.setAttribute('tabType', tabType); } connectedCallback() { @@ -76,13 +74,6 @@ class ItemPaneSectionElementBase extends XULElementBase { } } - /** - * @returns {boolean} if false, data change will not be saved - */ - _handleDataChange(_type, _value) { - return true; - } - _handleSectionToggle = async (event) => { if (event.target !== this._section || !this._section.open) { return; @@ -334,12 +325,10 @@ class ItemPaneSectionElementBase extends XULElementBase { this._hooks.toggle(props); }; - _handleDataChange(type, _oldValue, _newValue) { - if (type == "item" && this._hooks.itemChange) { - let props = this._assembleProps(this._getHookProps()); - this._hooks.itemChange(props); - } - return true; + _handleItemChange() { + if (!this._hooks.itemChange) return; + let props = this._assembleProps(this._getHookProps()); + this._hooks.itemChange(props); } }