Permalink
Browse files

Merge pull request #11 from stryju/patch-3

TODO: don't add class dups
  • Loading branch information...
protodave committed Jun 27, 2014
2 parents 1f09fd9 + 1814600 commit f2b59b75cbb61240e4d0032cfa66f59438710212
Showing with 18 additions and 2 deletions.
  1. +18 −2 svg-injector.js
View
@@ -14,6 +14,23 @@
var isLocal = window.location.protocol === 'file:';
var hasSvgSupport = document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
function mergeClasses( list ) {
list = list.split(' ');
var hash = {};
var i = list.length;
var out = [];
while (i--) {
if (!hash.hasOwnProperty(list[i])) {
hash[list[i]] = 1;
out.unshift(list[i]);
}
}
return out.join(' ');
}
// SVG Cache
var svgCache = {};
@@ -201,9 +218,8 @@
var imgClass = el.getAttribute('class');
if (imgClass) {
// :TODO: don't add dups
var classMerge = [svg.getAttribute('class'), 'iconic-injected-svg', imgClass].join(' ');
svg.setAttribute('class', classMerge);
svg.setAttribute('class', mergeClasses(classMerge));
}
var imgStyle = el.getAttribute('style');

0 comments on commit f2b59b7

Please sign in to comment.