Open aptogo opened 8 years ago
You can demonstrate the leak from zfIconic by using the Chrome Dev timeline while viewing http://foundation.zurb.com/apps/docs and repeatedly switching between the Iconic tab and the Typography tab.
ZURB has basically dropped support for this framework and it is now being maintained by the community as https://github.com/base-apps/angular-base-apps.
I've gone through the entire codebase and wrote an unsubscribed method for every subscribe method. Feel free to run the same analytics against v1.2.5 and create issues as needed.
From a code inspection, Foundation.unsubscribe(name, callback) removes ALL listeners for the specified name. This works as intended in the case where 'name' is the ID of a specific element (for example, in modal.js or notification.js). However, the subscribe/unsubscribe mechanism is also used for the global 'resize' event. In several places in the codebase, Foundation.unsubscribe('resize') is used. This will detach ALL listeners of the resize event, not just the intended listener (e.g interchange.js line 233).
In addition, in iconic.js, the zfIconic directive subscribes to 'resize' but does not 'unsubscribe' when it is destroyed. This will lead to leaking of detached DOM elements.
The Foundation.unsubscribe method should be changed to allow un-subscription of a specific listener and all subscriptions should be checked for matching un-subscriptions to prevent leaks.