Framework7 version: 3.6.6 (and 4.0.1 seems have that bug also)
Any platform
Describe the bug
Memory leak happens when event bound with once() and then unbound with off(). Event handler will not unbound.
To Reproduce
Run the kitchen-sink and watch for the memory allocations in the Chrome devtools. When open and close the "Photobrowser" component several times you will see multiple objects which have pointers to 'swipeBackMove'.
Expected behavior
Event handler unbound and removed
Actual Behavior
I seen this in the framework7-3.6.6/packages/core/js/framework7.js (line 6792)
function onModalLoaded() {
// Create Modal
var modal = app[modalType].create(modalParams);
modalRoute.modalInstance = modal;
var hasEl = modal.el;
function closeOnSwipeBack() {
modal.close();
}
modal.on((modalOrPanel + "Open"), function () {
if (!hasEl) {
// Remove theme elements
router.removeThemeElements(modal.el);
// Emit events
modal.$el.trigger(((modalType.toLowerCase()) + ":init " + (modalType.toLowerCase()) + ":mounted"), r
router.emit(((!isPanel ? 'modalInit' : '') + " " + modalType + "Init " + modalType + "Mounted"), mod
}
router.once('swipeBackMove', closeOnSwipeBack);
});
modal.on((modalOrPanel + "Close"), function () {
router.off('swipeBackMove', closeOnSwipeBack);
if (!modal.closeByRouter) {
router.back();
}
});
Event bound with router.once('swipeBackMove', closeOnSwipeBack) but failed to unbind in router.off('swipeBackMove', closeOnSwipeBack);
It happens because .once() create a wrapper function which bound with .on() and when router.off('swipeBackMove', closeOnSwipeBack); searches for closeOnSwipeBack() it does not found it and not unbound.
Describe the bug
Memory leak happens when event bound with once() and then unbound with off(). Event handler will not unbound.
To Reproduce
Run the kitchen-sink and watch for the memory allocations in the Chrome devtools. When open and close the "Photobrowser" component several times you will see multiple objects which have pointers to 'swipeBackMove'.
Expected behavior
Event handler unbound and removed
Actual Behavior
I seen this in the framework7-3.6.6/packages/core/js/framework7.js (line 6792)
Event bound with
router.once('swipeBackMove', closeOnSwipeBack)
but failed to unbind inrouter.off('swipeBackMove', closeOnSwipeBack);
It happens because .once() create a wrapper function which bound with .on() and when
router.off('swipeBackMove', closeOnSwipeBack);
searches for closeOnSwipeBack() it does not found it and not unbound.Screenshoot