Actual Behavior:
What is the issue? *What is the expected behavior? *CodePen (or steps to reproduce the issue): *
Details: Add aria-label="" to an md-icon with role="img" and/or add alt="" to an md-icon with role="img". Use a screen reader to navigate to the image element - It will be navigable by a screen reader but will have no label.AngularJS Versions: *
AngularJS Version:AngularJS Material Version: 1.1.4Additional Information:
Browser Type: * ChromeBrowser Version: * Version 58.0.3029.110 (64-bit)OS: * macOS Sieera Version 10.12.5Stack Traces:Screen Reader: Voiceover (likely others as well)@katiehockman - do you have a reproducible issue/Plunkr ?
@EladBezalel - can you fix this one also?
Note that the codepen is testing against 1.1.0.
Still, in master, there's no logic in mdIcon that checks if the attribute exists, only if it is truthy (if (attr.alt)). Performing a hasAttribute check would fix it. Alternatively, a null-check (alt == null) could work as well, though that would include an implicit conversion.
Here is an updated CodePen using latest/HEAD from AngularJS Material: https://codepen.io/angular-flex-layout/pen/eRBVpX

Note the link to explicitly load the material-design icons:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
The demo provided still has the issue where providing only an empty alt attribute still creates an aria-label with the inner HTML of the md-icon element. Since the documentation for alt says that "If an empty string is provided, icon will be hidden from accessibility layer", the current implementation will mislead users.
For example:
<md-icon alt="">something</md-icon>
creates
<md-icon alt="" aria-label="something">something</md-icon>
A few other thoughts/issues:
Most helpful comment
Note that the codepen is testing against 1.1.0.
Still, in master, there's no logic in
mdIconthat checks if the attribute exists, only if it is truthy (if (attr.alt)). Performing a hasAttribute check would fix it. Alternatively, a null-check (alt == null) could work as well, though that would include an implicit conversion.