diff --git a/docs/app/img/icons/sets/symbol-icons.svg b/docs/app/img/icons/sets/symbol-icons.svg new file mode 100644 index 00000000000..2c415ce4bd9 --- /dev/null +++ b/docs/app/img/icons/sets/symbol-icons.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/components/icon/demoSvgIconSets/index.html b/src/components/icon/demoSvgIconSets/index.html index fd84a2a9a05..6232abc3dbd 100644 --- a/src/components/icon/demoSvgIconSets/index.html +++ b/src/components/icon/demoSvgIconSets/index.html @@ -3,9 +3,11 @@

Display an icon from a pre-registered set of icons:

- - - + + + + +

diff --git a/src/components/icon/demoSvgIconSets/script.js b/src/components/icon/demoSvgIconSets/script.js index 2ebf6524c3a..b815a6d38a0 100644 --- a/src/components/icon/demoSvgIconSets/script.js +++ b/src/components/icon/demoSvgIconSets/script.js @@ -4,5 +4,6 @@ angular.module('appSvgIconSets', ['ngMaterial']) .config(['$mdIconProvider', function($mdIconProvider) { $mdIconProvider .iconSet('social', 'img/icons/sets/social-icons.svg', 24) + .iconSet('symbol', 'img/icons/sets/symbol-icons.svg', 24) .defaultIconSet('img/icons/sets/core-icons.svg', 24); }]); diff --git a/src/components/icon/icon.spec.js b/src/components/icon/icon.spec.js index 29f7b313996..d847fbb46d3 100644 --- a/src/components/icon/icon.spec.js +++ b/src/components/icon/icon.spec.js @@ -406,6 +406,7 @@ describe('MdIcon service', function() { .icon('android' , 'android.svg') .icon('c2' , 'c2.svg') .iconSet('social' , 'social.svg' ) + .iconSet('symbol' , 'symbol.svg' ) .iconSet('emptyIconSet' , 'emptyGroup.svg' ) .defaultIconSet('core.svg'); @@ -419,6 +420,7 @@ describe('MdIcon service', function() { $templateCache.put('android.svg' , ''); $templateCache.put('social.svg' , ''); + $templateCache.put('symbol.svg' , ''); $templateCache.put('core.svg' , ''); $templateCache.put('c2.svg' , ''); $templateCache.put('emptyGroup.svg' , ''); @@ -464,6 +466,22 @@ describe('MdIcon service', function() { $scope.$digest(); }); + it('should append configured SVG icon from symbol', function() { + var expected = updateDefaults(''); + $mdIcon('symbol:s1').then(function(el) { + expect(el.outerHTML).toEqual(expected); + }); + $scope.$digest(); + }); + + it('should append configured SVG icon from symbol with viewBox', function() { + var expected = updateDefaults(''); + $mdIcon('symbol:s2').then(function(el) { + expect(el.outerHTML).toEqual(expected); + }); + $scope.$digest(); + }); + it('should append configured SVG icon from default group', function() { var expected = updateDefaults(''); $mdIcon('c1').then(function(el) { diff --git a/src/components/icon/js/iconService.js b/src/components/icon/js/iconService.js index ac8ce8d18da..266b6a9faf8 100644 --- a/src/components/icon/js/iconService.js +++ b/src/components/icon/js/iconService.js @@ -575,7 +575,14 @@ function MdIconService(config, $templateRequest, $q, $log, $mdUtil, $sce) { * Define the Icon class */ function Icon(el, config) { - if (el && el.tagName != 'svg') { + // If the node is a , it won't be rendered so we have to convert it into . + if (el && el.tagName.toLowerCase() === 'symbol') { + var viewbox = el.getAttribute('viewBox'); + el = angular.element('').html(el.innerHTML)[0]; + if (viewbox) el.setAttribute('viewBox', viewbox); + } + + if (el && el.tagName.toLowerCase() !== 'svg') { el = angular.element('').append(el.cloneNode(true))[0]; }