naugtur/insertionQuery

crash on null element

Closed this issue · 3 comments

I'm using insertQ to disable intercom when doing a visual test of my site.

  if (intercomState == "false") {
	insertionQ('#intercom-container').every(function(element){
	   document.getElementById("intercom-container").style.display = "none";
	})
  }

This crashes as follows:
image

I patched/fixed it by testing for null/undefined as the first line of tagAll and it solved the problem

function tagAll(e) {
    if (!e) return;

BTW1 - the intercome icon still shows up briefly - is there a way to make it invisible before it appears?
BTW2 - I assume I could have written
element.style.display = "none" - correct ?

Thanks for this feature - it saved me..

Would you like to turn this into a pull request? If it's a single line, it should be doable through github UI. Would be nice to see you in the contributor list for that.

And yes, element is the element on which the event fired, so it has to match your initial selector.

merged