diff --git a/README.md b/README.md index 7cb6663..920a31e 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,9 @@ Include the SVGInject Javascript file in the `` element of the HTML docume ``` -Download plain version (v1.2.0): [svg-inject.js](https://raw.githubusercontent.com/iconfu/svg-inject/v1.2.0/dist/svg-inject.js) +Download plain version (v1.2.1): [svg-inject.js](https://raw.githubusercontent.com/iconfu/svg-inject/v1.2.1/dist/svg-inject.js) -Download minified version (v1.2.0): [svg-inject.min.js](https://raw.githubusercontent.com/iconfu/svg-inject/v1.2.0/dist/svg-inject.min.js) +Download minified version (v1.2.1): [svg-inject.min.js](https://raw.githubusercontent.com/iconfu/svg-inject/v1.2.1/dist/svg-inject.min.js) ### npm diff --git a/dist/svg-inject.js b/dist/svg-inject.js index e8e2016..d19db97 100644 --- a/dist/svg-inject.js +++ b/dist/svg-inject.js @@ -1,5 +1,5 @@ /** - * SVGInject - Version 1.2.0 + * SVGInject - Version 1.2.1 * A tiny, intuitive, robust, caching solution for injecting SVG files inline into the DOM. * * https://github.com/iconfu/svg-inject @@ -251,8 +251,9 @@ imgElem[__SVGINJECT] = INJECTED; removeOnLoadAttribute(imgElem); // Invoke afterInject hook if set - if (options.afterInject) { - options.afterInject(imgElem, injectElem); + var afterInject = options.afterInject; + if (afterInject) { + afterInject(imgElem, injectElem); } } } else { @@ -411,11 +412,11 @@ options = mergeOptions(defaultOptions, options); var run = function(resolve) { - var onAllFinish = function() { - if (options.onAllFinish) { - options.onAllFinish(); - } - + var allFinish = function() { + var onAllFinish = options.onAllFinish; + if (onAllFinish) { + onAllFinish(); + } resolve && resolve(); }; @@ -425,21 +426,21 @@ var injectCount = img[_LENGTH_]; if (injectCount == 0) { - onAllFinish(); + allFinish(); } else { - var onFinish = function() { + var finish = function() { if (++injectIndex == injectCount) { - onAllFinish(); + allFinish(); } }; for (var i = 0; i < injectCount; i++) { - SVGInjectElement(img[i], options, onFinish); + SVGInjectElement(img[i], options, finish); } } } else { // only one img element - SVGInjectElement(img, options, onAllFinish); + SVGInjectElement(img, options, allFinish); } }; diff --git a/dist/svg-inject.min.js b/dist/svg-inject.min.js index 87b0c87..0a8481e 100644 --- a/dist/svg-inject.min.js +++ b/dist/svg-inject.min.js @@ -1,9 +1,9 @@ -!function(o,l){var t,a,s="createElement",y="getElementsByTagName",g="length",A="style",d="title",E="undefined",h="setAttribute",b="getAttribute",k=null,w="__svgInject",x="--inject-",C=new RegExp(x+"\\d+","g"),S="LOAD_FAIL",r="SVG_NOT_SUPPORTED",I="SVG_INVALID",v=["src","alt","onload","onerror"],j=l[s]("a"),L=typeof SVGRect!=E,f={useCache:!0,copyAttributes:!0,makeIdsUnique:!0},G={clipPath:["clip-path"],"color-profile":k,cursor:k,filter:k,linearGradient:["fill","stroke"],marker:["marker", -"marker-end","marker-mid","marker-start"],mask:k,pattern:["fill","stroke"],radialGradient:["fill","stroke"]},c=1,u=2,N=1;function O(e){return(t=t||new XMLSerializer).serializeToString(e)}function T(e){var r,t,n,i,o=x+N++,a=e.querySelectorAll("[id]"),f={},c=[],u=!1;for(n=0;n