Merge pull request #14278 from Snuffleupagus/rm-removeChild

Replace the remaining `Node.removeChild()` instances with `Element.remove()`
This commit is contained in:
Tim van der Meij 2021-11-17 20:17:55 +01:00 committed by GitHub
commit 3dccaccbb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 14 deletions

View File

@ -50,6 +50,7 @@
"unicorn/no-instanceof-array": "error", "unicorn/no-instanceof-array": "error",
"unicorn/no-useless-spread": "error", "unicorn/no-useless-spread": "error",
"unicorn/prefer-date-now": "error", "unicorn/prefer-date-now": "error",
"unicorn/prefer-dom-node-remove": "error",
"unicorn/prefer-string-starts-ends-with": "error", "unicorn/prefer-string-starts-ends-with": "error",
// Possible errors // Possible errors

View File

@ -128,7 +128,7 @@ function updateEmbedElement(elem) {
var parentNode = elem.parentNode; var parentNode = elem.parentNode;
var nextSibling = elem.nextSibling; var nextSibling = elem.nextSibling;
if (parentNode) { if (parentNode) {
parentNode.removeChild(elem); elem.remove();
} }
elem.type = "text/html"; elem.type = "text/html";
elem.src = getEmbeddedViewerURL(elem.src); elem.src = getEmbeddedViewerURL(elem.src);

View File

@ -350,7 +350,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
this._document.body.appendChild(div); this._document.body.appendChild(div);
isFontReady(loadTestFontId, () => { isFontReady(loadTestFontId, () => {
this._document.body.removeChild(div); div.remove();
request.complete(); request.complete();
}); });
/** Hack end */ /** Hack end */

View File

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

View File

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

View File

@ -462,9 +462,7 @@ const Stepper = (function StepperClosure() {
var Stats = (function Stats() { var Stats = (function Stats() {
let stats = []; let stats = [];
function clear(node) { function clear(node) {
while (node.hasChildNodes()) { node.textContent = ""; // Remove any `node` contents from the DOM.
node.removeChild(node.lastChild);
}
} }
function getStatIndex(pageNumber) { function getStatIndex(pageNumber) {
for (let i = 0, ii = stats.length; i < ii; ++i) { for (let i = 0, ii = stats.length; i < ii; ++i) {
@ -490,8 +488,7 @@ var Stats = (function Stats() {
} }
const statsIndex = getStatIndex(pageNumber); const statsIndex = getStatIndex(pageNumber);
if (statsIndex !== false) { if (statsIndex !== false) {
const b = stats[statsIndex]; stats[statsIndex].div.remove();
this.panel.removeChild(b.div);
stats.splice(statsIndex, 1); stats.splice(statsIndex, 1);
} }
const wrapper = document.createElement("div"); const wrapper = document.createElement("div");

View File

@ -259,7 +259,7 @@ class PDFPageView {
case xfaLayerNode: case xfaLayerNode:
continue; continue;
} }
div.removeChild(node); node.remove();
} }
div.removeAttribute("data-loaded"); div.removeAttribute("data-loaded");
@ -540,7 +540,7 @@ class PDFPageView {
this.renderingState = RenderingStates.FINISHED; this.renderingState = RenderingStates.FINISHED;
if (this.loadingIconDiv) { if (this.loadingIconDiv) {
div.removeChild(this.loadingIconDiv); this.loadingIconDiv.remove();
delete this.loadingIconDiv; delete this.loadingIconDiv;
} }
return Promise.reject(new Error("pdfPage is not loaded")); return Promise.reject(new Error("pdfPage is not loaded"));
@ -644,7 +644,7 @@ class PDFPageView {
this.renderingState = RenderingStates.FINISHED; this.renderingState = RenderingStates.FINISHED;
if (this.loadingIconDiv) { if (this.loadingIconDiv) {
div.removeChild(this.loadingIconDiv); this.loadingIconDiv.remove();
delete this.loadingIconDiv; delete this.loadingIconDiv;
} }
this._resetZoomLayer(/* removeFromDOM = */ true); this._resetZoomLayer(/* removeFromDOM = */ true);