Skip to content

Commit 3daaa32

Browse files
committed
chore(release): 4.1.5
1 parent d6fdf94 commit 3daaa32

File tree

5 files changed

+44
-28
lines changed

5 files changed

+44
-28
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
<a name="4.1.5"></a>
6+
## [4.1.5](https://github.com/kisenka/svg-sprite-loader/compare/v4.1.4...v4.1.5) (2019-04-27)
7+
8+
9+
### Bug Fixes
10+
11+
* replace all instances of urls in attribute ([d6fdf94](https://github.com/kisenka/svg-sprite-loader/commit/d6fdf94)), closes [#300](https://github.com/kisenka/svg-sprite-loader/issues/300)
12+
13+
14+
515
<a name="4.1.4"></a>
616
## [4.1.4](https://github.com/kisenka/svg-sprite-loader/compare/v4.1.3...v4.1.4) (2019-04-27)
717

examples/browser-sprite-with-dll/build/dll.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -898,15 +898,13 @@ var arrayFrom = function (arrayLike) {
898898
return Array.prototype.slice.call(arrayLike, 0);
899899
};
900900

901-
var ua = navigator.userAgent;
902-
903901
var browser = {
904-
isChrome: /chrome/i.test(ua),
905-
isFirefox: /firefox/i.test(ua),
902+
isChrome: function () { return /chrome/i.test(navigator.userAgent); },
903+
isFirefox: function () { return /firefox/i.test(navigator.userAgent); },
906904

907905
// https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
908-
isIE: /msie/i.test(ua) || /trident/i.test(ua),
909-
isEdge: /edge/i.test(ua)
906+
isIE: function () { return /msie/i.test(navigator.userAgent) || /trident/i.test(navigator.userAgent); },
907+
isEdge: function () { return /edge/i.test(navigator.userAgent); }
910908
};
911909

912910
/**
@@ -1015,6 +1013,10 @@ function encoder(url) {
10151013
});
10161014
}
10171015

1016+
function escapeRegExp(str) {
1017+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
1018+
}
1019+
10181020
/**
10191021
* @param {NodeList} nodes
10201022
* @param {string} startsWith
@@ -1079,7 +1081,7 @@ var updateUrls = function (svg, references, startsWith, replaceWith) {
10791081
return attList.indexOf(localName) !== -1 && value.indexOf(("url(" + startsWithEncoded)) !== -1;
10801082
});
10811083

1082-
attrs.forEach(function (attr) { return attr.value = attr.value.replace(startsWithEncoded, replaceWithEncoded); });
1084+
attrs.forEach(function (attr) { return attr.value = attr.value.replace(new RegExp(escapeRegExp(startsWithEncoded), 'g'), replaceWithEncoded); });
10831085
updateReferences(references, startsWithEncoded, replaceWithEncoded);
10841086
};
10851087

@@ -1142,7 +1144,7 @@ var BrowserSprite = (function (Sprite$$1) {
11421144
moveGradientsOutsideSymbol(symbolNode.parentNode);
11431145
}
11441146

1145-
if (browser.isIE || browser.isEdge) {
1147+
if (browser.isIE() || browser.isEdge()) {
11461148
evalStylesIEWorkaround(symbolNode);
11471149
}
11481150
});
@@ -1182,7 +1184,7 @@ var BrowserSprite = (function (Sprite$$1) {
11821184
}
11831185

11841186
if (typeof cfg.moveGradientsOutsideSymbol === 'undefined') {
1185-
config.moveGradientsOutsideSymbol = browser.isFirefox;
1187+
config.moveGradientsOutsideSymbol = browser.isFirefox();
11861188
}
11871189
};
11881190

examples/browser-sprite/build/main.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -885,15 +885,13 @@ var arrayFrom = function (arrayLike) {
885885
return Array.prototype.slice.call(arrayLike, 0);
886886
};
887887

888-
var ua = navigator.userAgent;
889-
890888
var browser = {
891-
isChrome: /chrome/i.test(ua),
892-
isFirefox: /firefox/i.test(ua),
889+
isChrome: function () { return /chrome/i.test(navigator.userAgent); },
890+
isFirefox: function () { return /firefox/i.test(navigator.userAgent); },
893891

894892
// https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
895-
isIE: /msie/i.test(ua) || /trident/i.test(ua),
896-
isEdge: /edge/i.test(ua)
893+
isIE: function () { return /msie/i.test(navigator.userAgent) || /trident/i.test(navigator.userAgent); },
894+
isEdge: function () { return /edge/i.test(navigator.userAgent); }
897895
};
898896

899897
/**
@@ -1002,6 +1000,10 @@ function encoder(url) {
10021000
});
10031001
}
10041002

1003+
function escapeRegExp(str) {
1004+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
1005+
}
1006+
10051007
/**
10061008
* @param {NodeList} nodes
10071009
* @param {string} startsWith
@@ -1066,7 +1068,7 @@ var updateUrls = function (svg, references, startsWith, replaceWith) {
10661068
return attList.indexOf(localName) !== -1 && value.indexOf(("url(" + startsWithEncoded)) !== -1;
10671069
});
10681070

1069-
attrs.forEach(function (attr) { return attr.value = attr.value.replace(startsWithEncoded, replaceWithEncoded); });
1071+
attrs.forEach(function (attr) { return attr.value = attr.value.replace(new RegExp(escapeRegExp(startsWithEncoded), 'g'), replaceWithEncoded); });
10701072
updateReferences(references, startsWithEncoded, replaceWithEncoded);
10711073
};
10721074

@@ -1129,7 +1131,7 @@ var BrowserSprite = (function (Sprite$$1) {
11291131
moveGradientsOutsideSymbol(symbolNode.parentNode);
11301132
}
11311133

1132-
if (browser.isIE || browser.isEdge) {
1134+
if (browser.isIE() || browser.isEdge()) {
11331135
evalStylesIEWorkaround(symbolNode);
11341136
}
11351137
});
@@ -1169,7 +1171,7 @@ var BrowserSprite = (function (Sprite$$1) {
11691171
}
11701172

11711173
if (typeof cfg.moveGradientsOutsideSymbol === 'undefined') {
1172-
config.moveGradientsOutsideSymbol = browser.isFirefox;
1174+
config.moveGradientsOutsideSymbol = browser.isFirefox();
11731175
}
11741176
};
11751177

examples/custom-runtime-generator/build/main.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10266,15 +10266,13 @@ var arrayFrom = function (arrayLike) {
1026610266
return Array.prototype.slice.call(arrayLike, 0);
1026710267
};
1026810268

10269-
var ua = navigator.userAgent;
10270-
1027110269
var browser = {
10272-
isChrome: /chrome/i.test(ua),
10273-
isFirefox: /firefox/i.test(ua),
10270+
isChrome: function () { return /chrome/i.test(navigator.userAgent); },
10271+
isFirefox: function () { return /firefox/i.test(navigator.userAgent); },
1027410272

1027510273
// https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
10276-
isIE: /msie/i.test(ua) || /trident/i.test(ua),
10277-
isEdge: /edge/i.test(ua)
10274+
isIE: function () { return /msie/i.test(navigator.userAgent) || /trident/i.test(navigator.userAgent); },
10275+
isEdge: function () { return /edge/i.test(navigator.userAgent); }
1027810276
};
1027910277

1028010278
/**
@@ -10383,6 +10381,10 @@ function encoder(url) {
1038310381
});
1038410382
}
1038510383

10384+
function escapeRegExp(str) {
10385+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
10386+
}
10387+
1038610388
/**
1038710389
* @param {NodeList} nodes
1038810390
* @param {string} startsWith
@@ -10447,7 +10449,7 @@ var updateUrls = function (svg, references, startsWith, replaceWith) {
1044710449
return attList.indexOf(localName) !== -1 && value.indexOf(("url(" + startsWithEncoded)) !== -1;
1044810450
});
1044910451

10450-
attrs.forEach(function (attr) { return attr.value = attr.value.replace(startsWithEncoded, replaceWithEncoded); });
10452+
attrs.forEach(function (attr) { return attr.value = attr.value.replace(new RegExp(escapeRegExp(startsWithEncoded), 'g'), replaceWithEncoded); });
1045110453
updateReferences(references, startsWithEncoded, replaceWithEncoded);
1045210454
};
1045310455

@@ -10510,7 +10512,7 @@ var BrowserSprite = (function (Sprite$$1) {
1051010512
moveGradientsOutsideSymbol(symbolNode.parentNode);
1051110513
}
1051210514

10513-
if (browser.isIE || browser.isEdge) {
10515+
if (browser.isIE() || browser.isEdge()) {
1051410516
evalStylesIEWorkaround(symbolNode);
1051510517
}
1051610518
});
@@ -10550,7 +10552,7 @@ var BrowserSprite = (function (Sprite$$1) {
1055010552
}
1055110553

1055210554
if (typeof cfg.moveGradientsOutsideSymbol === 'undefined') {
10553-
config.moveGradientsOutsideSymbol = browser.isFirefox;
10555+
config.moveGradientsOutsideSymbol = browser.isFirefox();
1055410556
}
1055510557
};
1055610558

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svg-sprite-loader",
3-
"version": "4.1.4",
3+
"version": "4.1.5",
44
"description": "Webpack loader for creating SVG sprites",
55
"keywords": [
66
"svg",

0 commit comments

Comments
 (0)