Skip to content

Commit

Permalink
Merge pull request #11 from stryju/patch-3
Browse files Browse the repository at this point in the history
TODO: don't add class dups
  • Loading branch information
protodave committed Jun 27, 2014
2 parents 1f09fd9 + 1814600 commit f2b59b7
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions svg-injector.js
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit f2b59b7

Please sign in to comment.