Skip to content

Commit 8d9f374

Browse files
committed
fix(all): memory leaks
fixes #10459 fixes #10416 fixes #10286
1 parent be0b6a8 commit 8d9f374

File tree

13 files changed

+25
-21
lines changed

13 files changed

+25
-21
lines changed

src/components/action-sheet/action-sheet-component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export class ActionSheetCmp {
183183

184184
ngOnDestroy() {
185185
assert(this.gestureBlocker.blocked === false, 'gesture blocker must be already unblocked');
186+
this.d = null;
186187
this.gestureBlocker.destroy();
187188
}
188189
}

src/components/menu/menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ export class Menu {
516516
this.isOpen = isOpen;
517517
this._isAnimating = false;
518518

519-
this._events.destroy();
519+
this._events.unlistenAll();
520520
if (isOpen) {
521521
// Disable swipe to go back gesture
522522
this._gestureBlocker.block();

src/components/refresher/refresher.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ export class Refresher {
503503
* @private
504504
*/
505505
ngOnDestroy() {
506+
this._events.destroy();
506507
this._gesture.destroy();
507508
this._setListeners(false);
508509
}

src/components/tabs/tabs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ export class Tabs extends Ion implements AfterViewInit {
411411
if (opts.updateUrl !== false) {
412412
this._linker.navChange(DIRECTION_SWITCH);
413413
}
414+
assert(this.getSelected() === selectedTab, 'selected tab does not match');
414415
this._fireChangeEvent(selectedTab);
415416
});
416417
} else {
@@ -419,8 +420,6 @@ export class Tabs extends Ion implements AfterViewInit {
419420
}
420421

421422
_fireChangeEvent(selectedTab: Tab) {
422-
assert(this.getSelected() === selectedTab, 'selected tab does not match');
423-
424423
selectedTab.ionSelect.emit(selectedTab);
425424
this.ionChange.emit(selectedTab);
426425
}

src/gestures/drag-gesture.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class PanGesture {
6262
unlisten() {
6363
if (this.isListening) {
6464
this.gestute && this.gestute.release();
65-
this.events.destroy();
65+
this.events.unlistenAll();
6666
this.isListening = false;
6767
}
6868
}
@@ -71,7 +71,8 @@ export class PanGesture {
7171
this.gestute && this.gestute.destroy();
7272
this.gestute = null;
7373
this.unlisten();
74-
this.element = null;
74+
this.events.destroy();
75+
this.events = this.element = this.gestute = null;
7576
}
7677

7778
pointerDown(ev: any): boolean {

src/gestures/ui-event-manager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ export class UIEventManager {
4343
}
4444
}
4545

46-
destroy() {
46+
unlistenAll() {
4747
this.evts.forEach(unRegEvent => {
4848
unRegEvent();
4949
});
5050
this.evts.length = 0;
5151
}
52+
53+
destroy() {
54+
this.unlistenAll();
55+
this.evts = null;
56+
}
5257
}

src/navigation/nav-controller-base.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ export class NavControllerBase extends Ion implements NavController {
723723

724724
if (transition.isRoot()) {
725725
// this is the root transition
726-
// it's save to destroy this transition
726+
// it's safe to destroy this transition
727727
this._trnsCtrl.destroy(transition.trnsId);
728728

729729
// it's safe to enable the app again
@@ -909,13 +909,10 @@ export class NavControllerBase extends Ion implements NavController {
909909
view._destroy(this._renderer);
910910
}
911911

912-
// purge stack
913-
this._views.length = 0;
914-
915912
// release swipe back gesture and transition
916913
this._sbGesture && this._sbGesture.destroy();
917914
this._sbTrns && this._sbTrns.destroy();
918-
this._sbGesture = this._sbTrns = null;
915+
this._queue = this._views = this._sbGesture = this._sbTrns = null;
919916

920917
// Unregister navcontroller
921918
if (this.parent && this.parent.unregisterChildNav) {

src/navigation/view-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ export class ViewController {
523523
this._cmp.destroy();
524524
}
525525

526-
this._nav = this._cmp = this.instance = this._cntDir = this._cntRef = this._hdrDir = this._ftrDir = this._nb = this._onDidDismiss = this._onWillDismiss = null;
526+
this._nav = this._cmp = this.instance = this._cntDir = this._cntRef = this._leavingOpts = this._hdrDir = this._ftrDir = this._nb = this._onDidDismiss = this._onWillDismiss = null;
527527
}
528528

529529
/**

src/tap-click/ripple.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { DomController } from '../platform/dom-controller';
1010
* @private
1111
*/
1212
export class RippleActivator implements ActivatorBase {
13-
protected _queue: HTMLElement[] = [];
14-
protected _active: HTMLElement[] = [];
1513
protected highlight: Activator;
1614

1715
constructor(app: App, config: Config, private dom: DomController) {
@@ -52,8 +50,6 @@ export class RippleActivator implements ActivatorBase {
5250
return;
5351
}
5452

55-
this._active.push(activatableEle);
56-
5753
var j = activatableEle.childElementCount;
5854
while (j--) {
5955
var rippleEle: any = activatableEle.children[j];

src/tap-click/tap-click.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,13 @@ export class TapClick {
221221
}
222222

223223

224-
function getActivatableTarget(ele: HTMLElement) {
224+
function getActivatableTarget(ele: HTMLElement): any {
225225
let targetEle = ele;
226226
for (let x = 0; x < 10; x++) {
227227
if (!targetEle) break;
228-
if (isActivatable(targetEle)) return targetEle;
228+
if (isActivatable(targetEle)) {
229+
return targetEle;
230+
}
229231
targetEle = targetEle.parentElement;
230232
}
231233
return null;

0 commit comments

Comments
 (0)