danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.6k forks source link

fix: remove elements appended to body in ngf-select on $destroy #2056

Open ciaran-phillips opened 6 years ago

ciaran-phillips commented 6 years ago

If the directive is added to something other than a file input, it adds file input elements to the document body. Since these are outside of the element the directive is applied to, they aren't automatically removed at the end of its life.

The cleanup code for these elements already existed, but it was only being called once when the directive was first applied, and wasn't actually removing anything. Now it will be called on $destroy, and the file elements are correctly removed

ciaran-phillips commented 6 years ago

This fixes the memory leak previously described by @dani3l in #1222