Refactor ItemPaneSection#_handleDataChange

Remove unused _handleDataChange and rename it to _handleItemChange
This commit is contained in:
windingwind 2024-04-01 11:35:36 +08:00
parent db499fdf2b
commit ee6b9d7af7

View file

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