WebUI: remove child elements directly

This commit is contained in:
Chocobo1 2024-11-20 22:33:41 +08:00
commit 72e033db79
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
2 changed files with 4 additions and 9 deletions

View file

@ -535,8 +535,7 @@ window.qBittorrent.ContextMenu ??= (() => {
updateTagsSubMenu(tagList) { updateTagsSubMenu(tagList) {
const contextTagList = $("contextTagList"); const contextTagList = $("contextTagList");
while (contextTagList.firstChild !== null) contextTagList.replaceChildren();
contextTagList.removeChild(contextTagList.firstChild);
const createMenuItem = (text, imgURL, clickFn) => { const createMenuItem = (text, imgURL, clickFn) => {
const anchor = document.createElement("a"); const anchor = document.createElement("a");

View file

@ -288,8 +288,7 @@ window.qBittorrent.DynamicTable ??= (() => {
LocalPreferences.set("columns_order_" + this.dynamicTableDivId, val.join(",")); LocalPreferences.set("columns_order_" + this.dynamicTableDivId, val.join(","));
this.loadColumnsOrder(); this.loadColumnsOrder();
this.updateTableHeaders(); this.updateTableHeaders();
while (this.tableBody.firstChild) this.tableBody.replaceChildren();
this.tableBody.removeChild(this.tableBody.firstChild);
this.updateTable(true); this.updateTable(true);
} }
if (this.currentHeaderAction === "drag") { if (this.currentHeaderAction === "drag") {
@ -465,11 +464,8 @@ window.qBittorrent.DynamicTable ??= (() => {
this.showColumn(action, this.columns[action].visible === "0"); this.showColumn(action, this.columns[action].visible === "0");
}.bind(this); }.bind(this);
// recreate child nodes when reusing (enables the context menu to work correctly) // recreate child elements when reusing (enables the context menu to work correctly)
if (ul.hasChildNodes()) { ul.replaceChildren();
while (ul.firstChild)
ul.removeChild(ul.lastChild);
}
for (let i = 0; i < this.columns.length; ++i) { for (let i = 0; i < this.columns.length; ++i) {
const text = this.columns[i].caption; const text = this.columns[i].caption;