Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(typeahead): don't leak DOM nodes
Browse files Browse the repository at this point in the history
when `appendToBody` option is set to true and then scope is destroyed,
DOM is still polluted with popup.
This fix removes `$popup` from DOM, thus cleaning it
  • Loading branch information
AVVS authored and pkozlowski-opensource committed Oct 19, 2014
1 parent 689c4d0 commit 1f6c3c9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,13 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap

originalScope.$on('$destroy', function(){
$document.unbind('click', dismissClickHandler);
if (appendToBody) {
$popup.remove();
}
});

var $popup = $compile(popUpEl)(scope);
if ( appendToBody ) {
if (appendToBody) {
$document.find('body').append($popup);
} else {
element.after($popup);
Expand Down

0 comments on commit 1f6c3c9

Please sign in to comment.