Skip to content

Commit

Permalink
fix: use parentNode.insertBefore() for adding the node
Browse files Browse the repository at this point in the history
  • Loading branch information
erm1116 committed Jun 29, 2023
1 parent 7818da0 commit dce076e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions extensions/chromium/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ function updateEmbedElement(elem) {
elem.type = "text/html";
elem.src = getEmbeddedViewerURL(elem.src);

if (nextSibling) {
nextSibling.before(elem);
} else if (parentNode) {
parentNode.append(elem);
if (parentNode) {
// 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);
}
}

Expand Down

0 comments on commit dce076e

Please sign in to comment.