diff --git a/src/components/icon/iconDirective.js b/src/components/icon/iconDirective.js
index db34b3da260..5dabd5e6178 100644
--- a/src/components/icon/iconDirective.js
+++ b/src/components/icon/iconDirective.js
@@ -241,23 +241,22 @@ function mdIconDirective($mdIcon, $mdTheming, $mdAria ) {
if (!scope.svgIcon && !scope.svgSrc) {
if (scope.fontIcon) {
- element.addClass('md-font');
- element.addClass(scope.fontIcon);
+ element.addClass('md-font ' + scope.fontIcon);
}
if (scope.fontSet) {
element.addClass($mdIcon.fontSet(scope.fontSet));
}
- // For Material Design font icons, the class '.material-icons'
- // is auto-added IF a style has not been specified
-
- if (!scope.fontIcon && !scope.fontSet && !angular.isDefined(attr.class)) {
-
- element.addClass('material-icons');
+ if (shouldUseDefaultFontSet()) {
+ element.addClass($mdIcon.fontSet());
}
+
}
+ function shouldUseDefaultFontSet() {
+ return !scope.fontIcon && !scope.fontSet && !attr.hasOwnProperty('class');
+ }
}
}
}
diff --git a/src/components/icon/iconDirective.spec.js b/src/components/icon/iconDirective.spec.js
index 06edff8be69..92843a32af6 100644
--- a/src/components/icon/iconDirective.spec.js
+++ b/src/components/icon/iconDirective.spec.js
@@ -140,6 +140,18 @@ describe('mdIcon directive', function() {
});
+ it('should support custom default fontset', function() {
+ $mdIconProvider.defaultFontSet('fa');
+
+ el = make( '');
+ expect( clean(el.attr('class')) ).toEqual("fa");
+
+ el = make( 'apple');
+ expect(el.text()).toEqual('apple');
+ expect( clean(el.attr('class')) ).toEqual("fa");
+
+ });
+
it('should support clearing an invalid font alias', function() {
el = make( '');