rmm5t/jquery-timeago — pull request #163 by tomoto (2014-01-20 07:43:57+00:00)
Title: Automatic disposal of the timer when element is removed from DOM tree

Hi,

As some other folks requested before, I needed a mechanism to automatically release the timer in case the timeago-enabled elements were removed from the DOM tree. Here is my contribution of the implementation with the unit test cases. Hope it is helpful and high quality enough to get into the main branch.

As I respect the backward compatibility, I made this feature disabled by default and the application needs to set $.timeago.settings.autoDisposal to true to enable it. (Please feel free to change this default behavior if the backward compatibility were not a big concern.)

A small fix was also made to avoid the timer leak in case an element is initialized twice.

The enhanced unit test cases would make sure that the update stops (or does not stop) when an element is removed from DOM if autoDisposal is true (or false).

Best Regards,
Tomoto