Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit f5a9101

Browse files
author
Robert Messerle
committed
fix(icon): when specified, the defaultFontSet class should be used.
1 parent 778af93 commit f5a9101

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/components/icon/iconDirective.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,23 +241,22 @@ function mdIconDirective($mdIcon, $mdTheming, $mdAria ) {
241241
if (!scope.svgIcon && !scope.svgSrc) {
242242

243243
if (scope.fontIcon) {
244-
element.addClass('md-font');
245-
element.addClass(scope.fontIcon);
244+
element.addClass('md-font ' + scope.fontIcon);
246245
}
247246

248247
if (scope.fontSet) {
249248
element.addClass($mdIcon.fontSet(scope.fontSet));
250249
}
251250

252-
// For Material Design font icons, the class '.material-icons'
253-
// is auto-added IF a style has not been specified
254-
255-
if (!scope.fontIcon && !scope.fontSet && !angular.isDefined(attr.class)) {
256-
257-
element.addClass('material-icons');
251+
if (shouldUseDefaultFontSet()) {
252+
element.addClass($mdIcon.fontSet());
258253
}
254+
259255
}
260256

257+
function shouldUseDefaultFontSet() {
258+
return !scope.fontIcon && !scope.fontSet && !attr.hasOwnProperty('class');
259+
}
261260
}
262261
}
263262
}

src/components/icon/iconDirective.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ describe('mdIcon directive', function() {
140140

141141
});
142142

143+
it('should support custom default fontset', function() {
144+
$mdIconProvider.defaultFontSet('fa');
145+
146+
el = make( '<md-icon></md-icon>');
147+
expect( clean(el.attr('class')) ).toEqual("fa");
148+
149+
el = make( '<md-icon>apple</md-icon>');
150+
expect(el.text()).toEqual('apple');
151+
expect( clean(el.attr('class')) ).toEqual("fa");
152+
153+
});
154+
143155
it('should support clearing an invalid font alias', function() {
144156

145157
el = make( '<md-icon md-font-set="none" class="custom-cake"></md-icon>');

0 commit comments

Comments
 (0)