mgcrea/angular-strap — pull request #1264 by bloveridge (2014-11-10 17:04:30+00:00)
Title: Fixes JS exceptions and leaking event listeners as a result of 812350394...

Fixes JS exceptions and leaking event listeners as a result of 81235039438.

Clicking on the body calls hide(), which assumes $element is defined and tries to remove an event handler. Calling destroy ultimately sets $element to null, which causes subsequent calls to hide() to throw exceptions. Prior to this commit, destroy() did not clean up event listeners on the body element, so the only way those click handlers got removed was upon an actual click event which called harmlessly through hide(). As a result of setting $element to null, however, it could no longer harmlessly call through hide().

This resulted in both a lot of extra event listeners being registered on the body element and never cleaned up, and also a lot of exceptions being thrown any time a dropdown was removed by means of destroying its scope.