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

Commit

Permalink
fix(icon): when specified, the defaultFontSet class should be used.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Messerle committed Aug 4, 2015
1 parent 778af93 commit f5a9101
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/icon/iconDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
}
12 changes: 12 additions & 0 deletions src/components/icon/iconDirective.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ describe('mdIcon directive', function() {

});

it('should support custom default fontset', function() {
$mdIconProvider.defaultFontSet('fa');

el = make( '<md-icon></md-icon>');
expect( clean(el.attr('class')) ).toEqual("fa");

el = make( '<md-icon>apple</md-icon>');
expect(el.text()).toEqual('apple');
expect( clean(el.attr('class')) ).toEqual("fa");

});

it('should support clearing an invalid font alias', function() {

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

0 comments on commit f5a9101

Please sign in to comment.