1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Replace the remaining Node.removeChild() instances with Element.remove()

Using `Element.remove()` is a slightly more compact way of removing an element, since you no longer need to explicitly find/use its parent element.
Furthermore, the patch also replaces a couple of loops that're used to delete all elements under a node with simply overwriting the contents directly (a pattern already used throughout the viewer).

See also:
 - https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/remove
This commit is contained in:
Jonas Jenwald 2021-11-16 12:36:22 +01:00
parent e4f97a2a91
commit 4ef1a129fa
6 changed files with 9 additions and 14 deletions

View file

@ -565,7 +565,7 @@ var Driver = (function DriverClosure() {
}
const body = document.body;
while (body.lastChild !== this.end) {
body.removeChild(body.lastChild);
body.lastChild.remove();
}
const destroyedPromises = [];

View file

@ -245,9 +245,7 @@ window.onload = function () {
// const cell = ID("itemlist");
const table = document.getElementById("itemtable");
while (table.childNodes.length > 0) {
table.removeChild(table.childNodes[table.childNodes.length - 1]);
}
table.textContent = ""; // Remove any table contents from the DOM.
const tbody = document.createElement("tbody");
table.appendChild(tbody);