uzairfarooq / arrive

Watch for DOM elements creation and removal
MIT License
869 stars 99 forks source link

Function firing twice in Firefox 56 on 2.4.1 (regression from bug 54) #64

Open trlkly opened 6 years ago

trlkly commented 6 years ago

I have the following (simplified) code in my userscript for xkcd.com, running at document-start (using GreaseMonkey).

document.arrive('ul.comicNav', { onceOnly: true, existing: true }, func); //from @require
function func() { 
 console.log('test');
}

Not even adding document.unbindArrive('ul.comicNav') or Arrive.undbindAllArrive() seems to stop this.

This suggests that, even though I am unbinding the Arrive (either automatically or explicitly), both ul.comic.Nav instances are still causing func() to fire.

I have done regression testing, and this behavior seems to be due to the fix for #54. Ironically, in Firefox, it seems to be causing the very thing you were trying to prevent in that bug.

uzairfarooq commented 6 years ago

Hey @trlkly. I just created this fiddle https://jsfiddle.net/0r7du008/3/ to reproduce the issue but it seems to be firing only once. I'm using Firefox 55.0.3

trlkly commented 6 years ago

I have made a fiddle that does have the problem. The elements have to be created in HTML, and my code has to run before the elements are created, so I loaded the script in an external resource using a data: URI.

https://jsfiddle.net/0r7du008/5/

I note that this fires twice in Google Chrome as well.

My main use for arrive.js in userscripts is to make a change to the DOM right after an element is loaded from the HTML, but before it is rendered to the screen. That way there is no pop-in.

uzairfarooq commented 6 years ago

Ah, I see. Thanks for reporting, will fix it in a day or two.