Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"unicorn/no-instanceof-array": "error",
"unicorn/no-useless-spread": "error",
"unicorn/prefer-date-now": "error",
"unicorn/prefer-dom-node-remove": "error",
"unicorn/prefer-string-starts-ends-with": "error",

// Possible errors
Expand Down
2 changes: 1 addition & 1 deletion extensions/chromium/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function updateEmbedElement(elem) {
var parentNode = elem.parentNode;
var nextSibling = elem.nextSibling;
if (parentNode) {
parentNode.removeChild(elem);
elem.remove();
}
elem.type = "text/html";
elem.src = getEmbeddedViewerURL(elem.src);
Expand Down
2 changes: 1 addition & 1 deletion src/display/font_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
this._document.body.appendChild(div);

isFontReady(loadTestFontId, () => {
this._document.body.removeChild(div);
div.remove();
request.complete();
});
/** Hack end */
Expand Down
2 changes: 1 addition & 1 deletion test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
4 changes: 1 addition & 3 deletions test/resources/reftest-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
7 changes: 2 additions & 5 deletions web/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,7 @@ const Stepper = (function StepperClosure() {
var Stats = (function Stats() {
let stats = [];
function clear(node) {
while (node.hasChildNodes()) {
node.removeChild(node.lastChild);
}
node.textContent = ""; // Remove any `node` contents from the DOM.
}
function getStatIndex(pageNumber) {
for (let i = 0, ii = stats.length; i < ii; ++i) {
Expand All @@ -490,8 +488,7 @@ var Stats = (function Stats() {
}
const statsIndex = getStatIndex(pageNumber);
if (statsIndex !== false) {
const b = stats[statsIndex];
this.panel.removeChild(b.div);
stats[statsIndex].div.remove();
stats.splice(statsIndex, 1);
}
const wrapper = document.createElement("div");
Expand Down
6 changes: 3 additions & 3 deletions web/pdf_page_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class PDFPageView {
case xfaLayerNode:
continue;
}
div.removeChild(node);
node.remove();
}
div.removeAttribute("data-loaded");

Expand Down Expand Up @@ -534,7 +534,7 @@ class PDFPageView {
this.renderingState = RenderingStates.FINISHED;

if (this.loadingIconDiv) {
div.removeChild(this.loadingIconDiv);
this.loadingIconDiv.remove();
delete this.loadingIconDiv;
}
return Promise.reject(new Error("pdfPage is not loaded"));
Expand Down Expand Up @@ -617,7 +617,7 @@ class PDFPageView {
this.renderingState = RenderingStates.FINISHED;

if (this.loadingIconDiv) {
div.removeChild(this.loadingIconDiv);
this.loadingIconDiv.remove();
delete this.loadingIconDiv;
}
this._resetZoomLayer(/* removeFromDOM = */ true);
Expand Down