Skip to content

Commit

Permalink
Version 1.2.1
Browse files Browse the repository at this point in the history
fixed a bug introduced in 1.2.0 where cached SVGs might not get injected correctly
  • Loading branch information
dasboe committed Oct 25, 2018
1 parent 82510e0 commit 4494c13
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 70 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ Include the SVGInject Javascript file in the `<head>` element of the HTML docume
</head>
```

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

Expand Down
27 changes: 14 additions & 13 deletions dist/svg-inject.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
};

Expand All @@ -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);
}
};

Expand Down
18 changes: 9 additions & 9 deletions dist/svg-inject.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions examples/svg-inject.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
};

Expand All @@ -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);
}
};

Expand Down
Loading

0 comments on commit 4494c13

Please sign in to comment.