diff --git a/.eslintrc b/.eslintrc index 662e91da3dcaa..5e1210e27fff6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -55,6 +55,7 @@ "unicorn/prefer-date-now": "error", "unicorn/prefer-dom-node-append": "error", "unicorn/prefer-dom-node-remove": "error", + "unicorn/prefer-modern-dom-apis": "error", "unicorn/prefer-string-starts-ends-with": "error", // Possible errors diff --git a/extensions/chromium/contentscript.js b/extensions/chromium/contentscript.js index 749e1ae03888d..b0aa553000527 100644 --- a/extensions/chromium/contentscript.js +++ b/extensions/chromium/contentscript.js @@ -133,7 +133,7 @@ function updateEmbedElement(elem) { elem.type = "text/html"; elem.src = getEmbeddedViewerURL(elem.src); if (parentNode) { - parentNode.insertBefore(elem, nextSibling); + nextSibling.before(elem); } } diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index cd1bdb69a87e1..a6f3eb23a2b68 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -2559,9 +2559,9 @@ class AnnotationLayer { if (!firstChild) { element.append(canvas); } else if (firstChild.nodeName === "CANVAS") { - element.replaceChild(canvas, firstChild); + firstChild.replaceWith(canvas); } else { - element.insertBefore(canvas, firstChild); + firstChild.before(canvas); } } annotationCanvasMap.clear(); diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index acfdcf55734a7..1bf37459588c8 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -627,7 +627,7 @@ class PDFPageView { if (lastDivBeforeTextDiv) { // The annotation layer needs to stay on top. - div.insertBefore(canvasWrapper, lastDivBeforeTextDiv); + lastDivBeforeTextDiv.before(canvasWrapper); } else { div.append(canvasWrapper); } @@ -640,7 +640,7 @@ class PDFPageView { textLayerDiv.style.height = canvasWrapper.style.height; if (lastDivBeforeTextDiv) { // The annotation layer needs to stay on top. - div.insertBefore(textLayerDiv, lastDivBeforeTextDiv); + lastDivBeforeTextDiv.before(textLayerDiv); } else { div.append(textLayerDiv); }