Skip to content

Commit

Permalink
[CARE-5169] Fix client side exception
Browse files Browse the repository at this point in the history
It's happening on pages with Video node AND OneTrust cookie consent integration

> DOMException: Node.insertBefore: Child to insert before is not a child of this node
  • Loading branch information
e1himself committed May 31, 2024
1 parent 8cfd1b8 commit 3ff63bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/HtmlInjection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ function useScripts(html: Props['html'], onError: Props['onError']) {
// Iframely docs advise to insert their embed script before other scripts
if (attributes.src === IFRAMELY_EMBED_SCRIPT_SRC) {
const firstScript = document.body.getElementsByTagName('script')[0];
if (firstScript) {
document.body.insertBefore(script, firstScript);
if (firstScript && firstScript.parentNode) {
firstScript.parentNode.insertBefore(script, firstScript);
return;
}
}
Expand Down

0 comments on commit 3ff63bb

Please sign in to comment.