WebUI: remove child elements directly

This commit is contained in:
Chocobo1 2024-11-20 22:33:41 +08:00
parent e1bd1038c0
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) {
const contextTagList = $("contextTagList");
while (contextTagList.firstChild !== null)
contextTagList.removeChild(contextTagList.firstChild);
contextTagList.replaceChildren();
const createMenuItem = (text, imgURL, clickFn) => {
const anchor = document.createElement("a");

View file

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