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

Commit 1f6c3c9

Browse files
AVVSpkozlowski-opensource
authored andcommitted
fix(typeahead): don't leak DOM nodes
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
1 parent 689c4d0 commit 1f6c3c9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/typeahead/typeahead.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,13 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
311311

312312
originalScope.$on('$destroy', function(){
313313
$document.unbind('click', dismissClickHandler);
314+
if (appendToBody) {
315+
$popup.remove();
316+
}
314317
});
315318

316319
var $popup = $compile(popUpEl)(scope);
317-
if ( appendToBody ) {
320+
if (appendToBody) {
318321
$document.find('body').append($popup);
319322
} else {
320323
element.after($popup);

0 commit comments

Comments
 (0)