Created
August 9, 2015 10:03
-
-
Save smorcuend/15da9fa27d44ce7f72bd to your computer and use it in GitHub Desktop.
mdIconService from material-angularjs modified for support <use> tag on inline SVG sprites. (angular/material/src/components/icon/iconService.js)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Loads the reference of SVG element from icon set sprite using inline svg reference | |
*/ | |
function Icon(el, config) { | |
if (el.tagName != 'svg') { | |
el = angular.element('<svg><use xlink:href="' + config.url + '#' + el.id + '"/></svg>')[0]; | |
} | |
// Inject the namespace if not available... | |
if (!el.getAttribute('xmlns')) { | |
el.setAttribute('xmlns', "http://www.w3.org/2000/svg"); | |
} | |
this.element = el; | |
this.config = config; | |
this.prepare(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment