@@ -19,9 +19,7 @@ import {BreakPointRegistry} from '../breakpoints/break-point-registry';
19
19
@Injectable ( )
20
20
export class MockMatchMedia extends MatchMedia {
21
21
22
- /**
23
- * Special flag used to test BreakPoint registrations with MatchMedia
24
- */
22
+ /** Special flag used to test BreakPoint registrations with MatchMedia */
25
23
autoRegisterQueries = true ;
26
24
27
25
/**
@@ -37,9 +35,7 @@ export class MockMatchMedia extends MatchMedia {
37
35
this . _actives = [ ] ;
38
36
}
39
37
40
- /**
41
- * Easy method to clear all listeners for all mediaQueries
42
- */
38
+ /** Easy method to clear all listeners for all mediaQueries */
43
39
clearAll ( ) {
44
40
this . _registry . forEach ( ( mql : MockMediaQueryList , _ ) => {
45
41
mql . destroy ( ) ;
@@ -48,9 +44,7 @@ export class MockMatchMedia extends MatchMedia {
48
44
this . useOverlaps = false ;
49
45
}
50
46
51
- /**
52
- * Feature to support manual, simulated activation of a mediaQuery.
53
- */
47
+ /** Feature to support manual, simulated activation of a mediaQuery. */
54
48
activate ( mediaQuery : string , useOverlaps = false ) : boolean {
55
49
useOverlaps = useOverlaps || this . useOverlaps ;
56
50
mediaQuery = this . _validateQuery ( mediaQuery ) ;
@@ -65,9 +59,7 @@ export class MockMatchMedia extends MatchMedia {
65
59
return this . hasActivated ;
66
60
}
67
61
68
- /**
69
- * Converts an optional mediaQuery alias to a specific, valid mediaQuery
70
- */
62
+ /** Converts an optional mediaQuery alias to a specific, valid mediaQuery */
71
63
_validateQuery ( queryOrAlias ) {
72
64
let bp = this . _breakpoints . findByAlias ( queryOrAlias ) ;
73
65
if ( bp ) {
@@ -147,9 +139,7 @@ export class MockMatchMedia extends MatchMedia {
147
139
return this . hasActivated ;
148
140
}
149
141
150
- /**
151
- * Deactivate all current Mock MQLs
152
- */
142
+ /** Deactivate all current Mock MQLs */
153
143
private _deactivateAll ( ) {
154
144
if ( this . _actives . length ) {
155
145
// Deactivate all current MQLs and reset the buffer
@@ -161,9 +151,7 @@ export class MockMatchMedia extends MatchMedia {
161
151
return this ;
162
152
}
163
153
164
- /**
165
- * Insure the mediaQuery is registered with MatchMedia
166
- */
154
+ /** Insure the mediaQuery is registered with MatchMedia */
167
155
private _registerMediaQuery ( mediaQuery ) {
168
156
if ( ! this . _registry . has ( mediaQuery ) && this . autoRegisterQueries ) {
169
157
this . registerQuery ( mediaQuery ) ;
@@ -192,7 +180,7 @@ export class MockMatchMedia extends MatchMedia {
192
180
*/
193
181
export class MockMediaQueryList implements MediaQueryList {
194
182
private _isActive = false ;
195
- private _listeners : Array < MediaQueryListListener > = [ ] ;
183
+ private _listeners : MediaQueryListListener [ ] = [ ] ;
196
184
197
185
get matches ( ) : boolean {
198
186
return this . _isActive ;
@@ -202,20 +190,18 @@ export class MockMediaQueryList implements MediaQueryList {
202
190
return this . _mediaQuery ;
203
191
}
204
192
205
- constructor ( private _mediaQuery : string ) {
206
- }
193
+ constructor ( private _mediaQuery : string ) { }
207
194
208
195
/**
209
- *
196
+ * Destroy the current list by deactivating the
197
+ * listeners and clearing the internal list
210
198
*/
211
199
destroy ( ) {
212
200
this . deactivate ( ) ;
213
201
this . _listeners = [ ] ;
214
202
}
215
203
216
- /**
217
- * Notify all listeners that 'matches === TRUE'
218
- */
204
+ /** Notify all listeners that 'matches === TRUE' */
219
205
activate ( ) : MockMediaQueryList {
220
206
if ( ! this . _isActive ) {
221
207
this . _isActive = true ;
@@ -226,9 +212,7 @@ export class MockMediaQueryList implements MediaQueryList {
226
212
return this ;
227
213
}
228
214
229
- /**
230
- * Notify all listeners that 'matches === false'
231
- */
215
+ /** Notify all listeners that 'matches === false' */
232
216
deactivate ( ) : MockMediaQueryList {
233
217
if ( this . _isActive ) {
234
218
this . _isActive = false ;
@@ -239,9 +223,7 @@ export class MockMediaQueryList implements MediaQueryList {
239
223
return this ;
240
224
}
241
225
242
- /**
243
- *
244
- */
226
+ /** Add a listener to our internal list to activate later */
245
227
addListener ( listener : MediaQueryListListener ) {
246
228
if ( this . _listeners . indexOf ( listener ) === - 1 ) {
247
229
this . _listeners . push ( listener ) ;
@@ -251,6 +233,7 @@ export class MockMediaQueryList implements MediaQueryList {
251
233
}
252
234
}
253
235
236
+ /** Don't need to remove listeners in the testing environment */
254
237
removeListener ( _ : MediaQueryListListener ) {
255
238
}
256
239
}
0 commit comments