Twitter widget JS api : why don't destroy and stop clear the _resumeTimers timeouts from the window object?


Hello, I’m embedding multiple user configurable twitter widgets in a webapp.

When the user removes a widget, I call destroy on the widget api and then remove the markup from the DOM.

However I have found out that some timeout functions were still being executed after all this.

Even worse, those timeout functions actually manage to update the other twitter widgets in the page with tweets from the deleted widget.

This is because you call getByClass(c, tag, byId( to find the objects to update, and byId( returns null since I removed the markup from the DOM. so root is null and you fallback to the whole document like so : root = root || document;

So here are two suggestions :

Have the destroy and stop methods from the api clear the _resumeTimer timeouts like the pause method does.

Modify getByClass to return nothing if no root is specified to avoid affecting other widgets in the page.

for now I will just call pause() before calling destroy() to have things work correctly.

Thank you for you time.