Skip to content

Commit 4aaa431

Browse files
committed
fix(tab-link): avoid potential memory leak
Similarly to #1838, the `tab-link` destroy handler may not be called in certain situations, because it is being inherited from the MdRipple class. This PR explicitly calls the destroy handler.
1 parent 607de8f commit 4aaa431

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/lib/tabs/tab-nav-bar/tab-nav-bar.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import {Component, Input, ViewChild, ElementRef, ViewEncapsulation, Directive} from '@angular/core';
1+
import {
2+
Component,
3+
Input,
4+
ViewChild,
5+
ElementRef,
6+
ViewEncapsulation,
7+
Directive,
8+
OnDestroy,
9+
} from '@angular/core';
10+
211
import {MdInkBar} from '../ink-bar';
312
import {MdRipple} from '../../core/ripple/ripple';
413

@@ -50,8 +59,14 @@ export class MdTabLink {
5059
@Directive({
5160
selector: '[md-tab-link]',
5261
})
53-
export class MdTabLinkRipple extends MdRipple {
62+
export class MdTabLinkRipple extends MdRipple implements OnDestroy {
5463
constructor(private _element: ElementRef) {
5564
super(_element);
5665
}
66+
67+
// In certain cases the parent destroy handler
68+
// may not get called. See Angular issue #11606.
69+
ngOnDestroy() {
70+
super.ngOnDestroy();
71+
}
5772
}

0 commit comments

Comments
 (0)