From fcf38f6ae9623a01bd67d0dff8f99042255f993f Mon Sep 17 00:00:00 2001 From: erm1116 Date: Tue, 27 Jun 2023 20:50:25 +0900 Subject: [PATCH] fix: use node.insertBefore for adding embed element --- extensions/chromium/contentscript.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/chromium/contentscript.js b/extensions/chromium/contentscript.js index b0aa55300..1e596c493 100644 --- a/extensions/chromium/contentscript.js +++ b/extensions/chromium/contentscript.js @@ -132,8 +132,12 @@ function updateEmbedElement(elem) { } elem.type = "text/html"; elem.src = getEmbeddedViewerURL(elem.src); + if (parentNode) { - nextSibling.before(elem); + // Suppress linter warning: insertBefore is preferable to + // nextSibling.before(elem) because nextSibling may be null. + // eslint-disable-next-line unicorn/prefer-modern-dom-apis + parentNode.insertBefore(elem, nextSibling); } }