exit-intent-popup
exit-intent-popup copied to clipboard
[BUGFIX] Add style before first <link // solves #28
👍 for this PR to be merged, but may I suggest another change for it @misterboe ?
how about:
var firstHeadChild = document.head.firstElementChild;
document.head.insertBefore(style, firstHeadChild);
rather than simply:
document.getElementsByTagName("link")[0]
This would make sure the error doesn't happen when there are no link
s on header.
Just to shed some light on this issue, the error @misterboe is trying to fix is when bioEp tries to insert the exit intent styles in head
DOM element, before the first occurence of a style
. The problem arises when this first occurence of style
is not inside head
, but, rather, inside body
.
The error message is this:
Uncaught DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node
Hope this helps.