@@ -13,30 +13,6 @@ import {
1313 MDCTabIndicatorFoundation
1414} from '@material/tab-indicator' ;
1515
16- class TabIndicatorAdapter implements MDCTabIndicatorAdapter {
17- constructor ( private readonly _delegate : MatInkBarFoundation ) { }
18- addClass ( className : string ) {
19- if ( ! this . _delegate . _destroyed ) {
20- this . _delegate . _hostElement . classList . add ( className ) ;
21- }
22- }
23- removeClass ( className : string ) {
24- if ( ! this . _delegate . _destroyed ) {
25- this . _delegate . _hostElement . classList . remove ( className ) ;
26- }
27- }
28- setContentStyleProperty ( propName : string , value : string | null ) {
29- this . _delegate . _inkBarContentElement . style . setProperty ( propName , value ) ;
30- }
31- computeContentClientRect ( ) {
32- // `getBoundingClientRect` isn't available on the server.
33- return this . _delegate . _destroyed ||
34- ! this . _delegate . _inkBarContentElement . getBoundingClientRect ? {
35- width : 0 , height : 0 , top : 0 , left : 0 , right : 0 , bottom : 0
36- } : this . _delegate . _inkBarContentElement . getBoundingClientRect ( ) ;
37- }
38- }
39-
4016/**
4117 * Item inside a tab header relative to which the ink bar can be aligned.
4218 * @docs -private
@@ -86,15 +62,34 @@ export class MatInkBar {
8662 * @docs -private
8763 */
8864export class MatInkBarFoundation {
89- readonly _destroyed : boolean ;
65+ private _destroyed : boolean ;
9066 private _foundation : MDCTabIndicatorFoundation ;
9167 private _inkBarElement : HTMLElement ;
92- readonly _inkBarContentElement : HTMLElement ;
68+ private _inkBarContentElement : HTMLElement ;
9369 private _fitToContent = false ;
94- private _adapter : MDCTabIndicatorAdapter ;
70+ private _adapter : MDCTabIndicatorAdapter = {
71+ addClass : className => {
72+ if ( ! this . _destroyed ) {
73+ this . _hostElement . classList . add ( className ) ;
74+ }
75+ } ,
76+ removeClass : className => {
77+ if ( ! this . _destroyed ) {
78+ this . _hostElement . classList . remove ( className ) ;
79+ }
80+ } ,
81+ setContentStyleProperty : ( propName , value ) => {
82+ this . _inkBarContentElement . style . setProperty ( propName , value ) ;
83+ } ,
84+ computeContentClientRect : ( ) => {
85+ // `getBoundingClientRect` isn't available on the server.
86+ return this . _destroyed || ! this . _inkBarContentElement . getBoundingClientRect ? {
87+ width : 0 , height : 0 , top : 0 , left : 0 , right : 0 , bottom : 0
88+ } : this . _inkBarContentElement . getBoundingClientRect ( ) ;
89+ }
90+ } ;
9591
96- constructor ( readonly _hostElement : HTMLElement , private _document : Document ) {
97- this . _adapter = new TabIndicatorAdapter ( this ) ;
92+ constructor ( private _hostElement : HTMLElement , private _document : Document ) {
9893 this . _foundation = new MDCSlidingTabIndicatorFoundation ( this . _adapter ) ;
9994 }
10095
@@ -125,10 +120,9 @@ export class MatInkBarFoundation {
125120 this . _inkBarElement . parentNode . removeChild ( this . _inkBarElement ) ;
126121 }
127122
128- ( this as { _hostElement : HTMLElement } ) . _hostElement = this . _inkBarElement
129- = ( this as { _inkBarContentElement : HTMLElement } ) . _inkBarContentElement = null ! ;
123+ this . _hostElement = this . _inkBarElement = this . _inkBarContentElement = null ! ;
130124 this . _foundation . destroy ( ) ;
131- ( this as { _destroyed : boolean } ) . _destroyed = true ;
125+ this . _destroyed = true ;
132126 }
133127
134128 /**
@@ -154,8 +148,7 @@ export class MatInkBarFoundation {
154148 /** Creates and appends the ink bar element. */
155149 private _createInkBarElement ( ) {
156150 this . _inkBarElement = this . _document . createElement ( 'span' ) ;
157- ( this as { _inkBarContentElement : HTMLElement } ) . _inkBarContentElement
158- = this . _document . createElement ( 'span' ) ;
151+ this . _inkBarContentElement = this . _document . createElement ( 'span' ) ;
159152
160153 this . _inkBarElement . className = 'mdc-tab-indicator' ;
161154 this . _inkBarContentElement . className = 'mdc-tab-indicator__content' +
0 commit comments