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

Bug: FoundationApi.unsubscribe causes potential leaks and unintended sideffects #804

Open
aptogo opened this issue Apr 9, 2016 · 2 comments

Comments

@aptogo
Copy link

aptogo commented Apr 9, 2016

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.

@aptogo
Copy link
Author

aptogo commented Apr 9, 2016

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.

screenshot 2016-04-09 11 18 52

@soumak77
Copy link
Contributor

soumak77 commented Aug 1, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants