@@ -41,7 +41,6 @@ describe('MdIcon', () => {
4141 declarations : [
4242 MdIconColorTestApp ,
4343 MdIconLigatureTestApp ,
44- MdIconLigatureWithAriaBindingTestApp ,
4544 MdIconCustomFontCssTestApp ,
4645 MdIconFromSvgNameTestApp ,
4746 ] ,
@@ -121,15 +120,12 @@ describe('MdIcon', () => {
121120 fixture . detectChanges ( ) ;
122121 svgElement = verifyAndGetSingleSvgChild ( mdIconElement ) ;
123122 verifyPathChildElement ( svgElement , 'woof' ) ;
124- // The aria label should be taken from the icon name.
125- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'fido' ) ;
126123
127124 // Change the icon, and the SVG element should be replaced.
128125 testComponent . iconName = 'fluffy' ;
129126 fixture . detectChanges ( ) ;
130127 svgElement = verifyAndGetSingleSvgChild ( mdIconElement ) ;
131128 verifyPathChildElement ( svgElement , 'meow' ) ;
132- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'fluffy' ) ;
133129
134130 expect ( httpRequestUrls ) . toEqual ( [ 'dog.svg' , 'cat.svg' ] ) ;
135131 // Using an icon from a previously loaded URL should not cause another HTTP request.
@@ -181,8 +177,6 @@ describe('MdIcon', () => {
181177 expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'g' ) ;
182178 expect ( svgChild . getAttribute ( 'id' ) ) . toBe ( 'pig' ) ;
183179 verifyPathChildElement ( svgChild , 'oink' ) ;
184- // The aria label should be taken from the icon name (without the icon set portion).
185- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'pig' ) ;
186180
187181 // Change the icon, and the SVG element should be replaced.
188182 testComponent . iconName = 'farm:cow' ;
@@ -193,7 +187,6 @@ describe('MdIcon', () => {
193187 expect ( svgChild . tagName . toLowerCase ( ) ) . toBe ( 'g' ) ;
194188 expect ( svgChild . getAttribute ( 'id' ) ) . toBe ( 'cow' ) ;
195189 verifyPathChildElement ( svgChild , 'moo' ) ;
196- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'cow' ) ;
197190 } ) ;
198191
199192 it ( 'should allow multiple icon sets in a namespace' , ( ) => {
@@ -218,8 +211,6 @@ describe('MdIcon', () => {
218211 expect ( svgChild . getAttribute ( 'id' ) ) . toBe ( 'pig' ) ;
219212 expect ( svgChild . childNodes . length ) . toBe ( 1 ) ;
220213 verifyPathChildElement ( svgChild , 'oink' ) ;
221- // The aria label should be taken from the icon name (without the namespace).
222- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'pig' ) ;
223214
224215 // Both icon sets registered in the 'farm' namespace should have been fetched.
225216 expect ( httpRequestUrls . sort ( ) ) . toEqual ( [ 'farm-set-1.svg' , 'farm-set-2.svg' ] ) ;
@@ -236,7 +227,6 @@ describe('MdIcon', () => {
236227 expect ( svgChild . getAttribute ( 'id' ) ) . toBe ( 'cow' ) ;
237228 expect ( svgChild . childNodes . length ) . toBe ( 1 ) ;
238229 verifyPathChildElement ( svgChild , 'moo moo' ) ;
239- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'cow' ) ;
240230 expect ( httpRequestUrls . sort ( ) ) . toEqual ( [ 'farm-set-1.svg' , 'farm-set-2.svg' ] ) ;
241231 } ) ;
242232
@@ -255,7 +245,6 @@ describe('MdIcon', () => {
255245 // directly and not wrapped in an outer <svg> tag like the <g> elements in other sets.
256246 svgElement = verifyAndGetSingleSvgChild ( mdIconElement ) ;
257247 verifyPathChildElement ( svgElement , 'left' ) ;
258- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'left-arrow' ) ;
259248 } ) ;
260249
261250 it ( 'should return unmodified copies of icons from icon sets' , ( ) => {
@@ -302,89 +291,16 @@ describe('MdIcon', () => {
302291 testComponent . fontIcon = 'house' ;
303292 fixture . detectChanges ( ) ;
304293 expect ( sortedClassNames ( mdIconElement ) ) . toEqual ( [ 'font1' , 'house' , 'mat-icon' ] ) ;
305- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'house' ) ;
306294
307295 testComponent . fontSet = 'f2' ;
308296 testComponent . fontIcon = 'igloo' ;
309297 fixture . detectChanges ( ) ;
310298 expect ( sortedClassNames ( mdIconElement ) ) . toEqual ( [ 'f2' , 'igloo' , 'mat-icon' ] ) ;
311- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'igloo' ) ;
312299
313300 testComponent . fontSet = 'f3' ;
314301 testComponent . fontIcon = 'tent' ;
315302 fixture . detectChanges ( ) ;
316303 expect ( sortedClassNames ( mdIconElement ) ) . toEqual ( [ 'f3' , 'mat-icon' , 'tent' ] ) ;
317- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'tent' ) ;
318- } ) ;
319- } ) ;
320-
321- describe ( 'aria label' , ( ) => {
322- it ( 'should set aria label from text content if not specified' , ( ) => {
323- let fixture = TestBed . createComponent ( MdIconLigatureTestApp ) ;
324-
325- const testComponent = fixture . componentInstance ;
326- const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
327- testComponent . iconName = 'home' ;
328-
329- fixture . detectChanges ( ) ;
330- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'home' ) ;
331-
332- testComponent . iconName = 'hand' ;
333- fixture . detectChanges ( ) ;
334- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'hand' ) ;
335- } ) ;
336-
337- it ( 'should not set aria label unless it actually changed' , ( ) => {
338- let fixture = TestBed . createComponent ( MdIconLigatureTestApp ) ;
339-
340- const testComponent = fixture . componentInstance ;
341- const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
342- testComponent . iconName = 'home' ;
343-
344- fixture . detectChanges ( ) ;
345- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'home' ) ;
346-
347- mdIconElement . removeAttribute ( 'aria-label' ) ;
348- fixture . detectChanges ( ) ;
349- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBeFalsy ( ) ;
350- } ) ;
351-
352- it ( 'should use alt tag if aria label is not specified' , ( ) => {
353- let fixture = TestBed . createComponent ( MdIconLigatureWithAriaBindingTestApp ) ;
354-
355- const testComponent = fixture . componentInstance ;
356- const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
357- testComponent . iconName = 'home' ;
358- testComponent . altText = 'castle' ;
359- fixture . detectChanges ( ) ;
360- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'castle' ) ;
361-
362- testComponent . ariaLabel = 'house' ;
363- fixture . detectChanges ( ) ;
364- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'house' ) ;
365- } ) ;
366-
367- it ( 'should use provided aria label rather than icon name' , ( ) => {
368- let fixture = TestBed . createComponent ( MdIconLigatureWithAriaBindingTestApp ) ;
369-
370- const testComponent = fixture . componentInstance ;
371- const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
372- testComponent . iconName = 'home' ;
373- testComponent . ariaLabel = 'house' ;
374- fixture . detectChanges ( ) ;
375- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'house' ) ;
376- } ) ;
377-
378- it ( 'should use provided aria label rather than font icon' , ( ) => {
379- let fixture = TestBed . createComponent ( MdIconCustomFontCssTestApp ) ;
380-
381- const testComponent = fixture . componentInstance ;
382- const mdIconElement = fixture . debugElement . nativeElement . querySelector ( 'md-icon' ) ;
383- testComponent . fontSet = 'f1' ;
384- testComponent . fontIcon = 'house' ;
385- testComponent . ariaLabel = 'home' ;
386- fixture . detectChanges ( ) ;
387- expect ( mdIconElement . getAttribute ( 'aria-label' ) ) . toBe ( 'home' ) ;
388304 } ) ;
389305 } ) ;
390306
@@ -431,35 +347,24 @@ describe('MdIcon without HttpModule', () => {
431347/** Test components that contain an MdIcon. */
432348@Component ( { template : `<md-icon>{{iconName}}</md-icon>` } )
433349class MdIconLigatureTestApp {
434- ariaLabel : string = null ;
435350 iconName = '' ;
436351}
437352
438353@Component ( { template : `<md-icon [color]="iconColor">{{iconName}}</md-icon>` } )
439354class MdIconColorTestApp {
440- ariaLabel : string = null ;
441355 iconName = '' ;
442356 iconColor = 'primary' ;
443357}
444358
445- @Component ( { template : `<md-icon [aria-label]="ariaLabel" [alt]="altText">{{iconName}}</md-icon>` } )
446- class MdIconLigatureWithAriaBindingTestApp {
447- altText : string = '' ;
448- ariaLabel : string = null ;
449- iconName = '' ;
450- }
451-
452359@Component ( {
453- template : `<md-icon [fontSet]="fontSet" [fontIcon]="fontIcon" [aria-label]="ariaLabel" ></md-icon>`
360+ template : `<md-icon [fontSet]="fontSet" [fontIcon]="fontIcon"></md-icon>`
454361} )
455362class MdIconCustomFontCssTestApp {
456- ariaLabel : string = null ;
457363 fontSet = '' ;
458364 fontIcon = '' ;
459365}
460366
461- @Component ( { template : `<md-icon [svgIcon]="iconName" [aria-label]="ariaLabel" ></md-icon>` } )
367+ @Component ( { template : `<md-icon [svgIcon]="iconName"></md-icon>` } )
462368class MdIconFromSvgNameTestApp {
463- ariaLabel : string = null ;
464369 iconName = '' ;
465370}
0 commit comments