exit-intent-popup icon indicating copy to clipboard operation
exit-intent-popup copied to clipboard

[BUGFIX] Add style before first <link // solves #28

Open misterboe opened this issue 7 years ago • 1 comments

misterboe avatar Dec 13 '17 10:12 misterboe

👍 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 links 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.

tdtadeu avatar May 03 '19 14:05 tdtadeu