Skip to content

Commit

Permalink
Merge pull request #83 from prezly/fix/care-5169-client-side-exception
Browse files Browse the repository at this point in the history
[CARE-5169] Fix client side exception
  • Loading branch information
e1himself authored May 31, 2024
2 parents 8cfd1b8 + bcd6f27 commit 0902234
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/HtmlInjection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ 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);
const firstScript = document.querySelectorAll('body > script')[0];
if (firstScript && firstScript.parentNode) {
firstScript.parentNode.insertBefore(script, firstScript);
return;
}
}
Expand Down

0 comments on commit 0902234

Please sign in to comment.