@@ -13,30 +13,6 @@ import {
13
13
MDCTabIndicatorFoundation
14
14
} from '@material/tab-indicator' ;
15
15
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
-
40
16
/**
41
17
* Item inside a tab header relative to which the ink bar can be aligned.
42
18
* @docs -private
@@ -86,15 +62,34 @@ export class MatInkBar {
86
62
* @docs -private
87
63
*/
88
64
export class MatInkBarFoundation {
89
- readonly _destroyed : boolean ;
65
+ private _destroyed : boolean ;
90
66
private _foundation : MDCTabIndicatorFoundation ;
91
67
private _inkBarElement : HTMLElement ;
92
- readonly _inkBarContentElement : HTMLElement ;
68
+ private _inkBarContentElement : HTMLElement ;
93
69
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
+ } ;
95
91
96
- constructor ( readonly _hostElement : HTMLElement , private _document : Document ) {
97
- this . _adapter = new TabIndicatorAdapter ( this ) ;
92
+ constructor ( private _hostElement : HTMLElement , private _document : Document ) {
98
93
this . _foundation = new MDCSlidingTabIndicatorFoundation ( this . _adapter ) ;
99
94
}
100
95
@@ -125,10 +120,9 @@ export class MatInkBarFoundation {
125
120
this . _inkBarElement . parentNode . removeChild ( this . _inkBarElement ) ;
126
121
}
127
122
128
- ( this as { _hostElement : HTMLElement } ) . _hostElement = this . _inkBarElement
129
- = ( this as { _inkBarContentElement : HTMLElement } ) . _inkBarContentElement = null ! ;
123
+ this . _hostElement = this . _inkBarElement = this . _inkBarContentElement = null ! ;
130
124
this . _foundation . destroy ( ) ;
131
- ( this as { _destroyed : boolean } ) . _destroyed = true ;
125
+ this . _destroyed = true ;
132
126
}
133
127
134
128
/**
@@ -154,8 +148,7 @@ export class MatInkBarFoundation {
154
148
/** Creates and appends the ink bar element. */
155
149
private _createInkBarElement ( ) {
156
150
this . _inkBarElement = this . _document . createElement ( 'span' ) ;
157
- ( this as { _inkBarContentElement : HTMLElement } ) . _inkBarContentElement
158
- = this . _document . createElement ( 'span' ) ;
151
+ this . _inkBarContentElement = this . _document . createElement ( 'span' ) ;
159
152
160
153
this . _inkBarElement . className = 'mdc-tab-indicator' ;
161
154
this . _inkBarContentElement . className = 'mdc-tab-indicator__content' +
0 commit comments