@tanem/svg-injector 10.1.34 → 10.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/svg-injector.cjs.development.js +20 -77
- package/dist/svg-injector.cjs.development.js.map +1 -1
- package/dist/svg-injector.cjs.production.js.map +1 -1
- package/dist/svg-injector.esm.js +20 -77
- package/dist/svg-injector.esm.js.map +1 -1
- package/dist/svg-injector.umd.development.js +20 -77
- package/dist/svg-injector.umd.development.js.map +1 -1
- package/dist/svg-injector.umd.production.js.map +1 -1
- package/package.json +14 -14
package/dist/svg-injector.esm.js
CHANGED
|
@@ -13,28 +13,22 @@ var isLocal = function isLocal() {
|
|
|
13
13
|
|
|
14
14
|
var makeAjaxRequest = function makeAjaxRequest(url, httpRequestWithCredentials, callback) {
|
|
15
15
|
var httpRequest = new XMLHttpRequest();
|
|
16
|
-
|
|
17
16
|
httpRequest.onreadystatechange = function () {
|
|
18
17
|
try {
|
|
19
18
|
if (!/\.svg/i.test(url) && httpRequest.readyState === 2) {
|
|
20
19
|
var contentType = httpRequest.getResponseHeader('Content-Type');
|
|
21
|
-
|
|
22
20
|
if (!contentType) {
|
|
23
21
|
throw new Error('Content type not found');
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
var type = parse(contentType).type;
|
|
27
|
-
|
|
28
24
|
if (!(type === 'image/svg+xml' || type === 'text/plain')) {
|
|
29
25
|
throw new Error("Invalid content type: ".concat(type));
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
if (httpRequest.readyState === 4) {
|
|
34
29
|
if (httpRequest.status === 404 || httpRequest.responseXML === null) {
|
|
35
30
|
throw new Error(isLocal() ? 'Note: SVG injection ajax calls do not work locally without ' + 'adjusting security settings in your browser. Or consider ' + 'using a local webserver.' : 'Unable to load SVG file: ' + url);
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
if (httpRequest.status === 200 || isLocal() && httpRequest.status === 0) {
|
|
39
33
|
callback(null, httpRequest);
|
|
40
34
|
} else {
|
|
@@ -43,7 +37,6 @@ var makeAjaxRequest = function makeAjaxRequest(url, httpRequestWithCredentials,
|
|
|
43
37
|
}
|
|
44
38
|
} catch (error) {
|
|
45
39
|
httpRequest.abort();
|
|
46
|
-
|
|
47
40
|
if (error instanceof Error) {
|
|
48
41
|
callback(error, httpRequest);
|
|
49
42
|
} else {
|
|
@@ -51,14 +44,11 @@ var makeAjaxRequest = function makeAjaxRequest(url, httpRequestWithCredentials,
|
|
|
51
44
|
}
|
|
52
45
|
}
|
|
53
46
|
};
|
|
54
|
-
|
|
55
47
|
httpRequest.open('GET', url);
|
|
56
48
|
httpRequest.withCredentials = httpRequestWithCredentials;
|
|
57
|
-
|
|
58
49
|
if (httpRequest.overrideMimeType) {
|
|
59
50
|
httpRequest.overrideMimeType('text/xml');
|
|
60
51
|
}
|
|
61
|
-
|
|
62
52
|
httpRequest.send();
|
|
63
53
|
};
|
|
64
54
|
|
|
@@ -73,22 +63,18 @@ var processRequestQueue = function processRequestQueue(url) {
|
|
|
73
63
|
if (Array.isArray(requestQueue[url])) {
|
|
74
64
|
var cacheValue = cache.get(url);
|
|
75
65
|
var callback = requestQueue[url][i];
|
|
76
|
-
|
|
77
66
|
if (cacheValue instanceof SVGSVGElement) {
|
|
78
67
|
callback(null, cloneSvg(cacheValue));
|
|
79
68
|
}
|
|
80
|
-
|
|
81
69
|
if (cacheValue instanceof Error) {
|
|
82
70
|
callback(cacheValue);
|
|
83
71
|
}
|
|
84
|
-
|
|
85
72
|
if (i === requestQueue[url].length - 1) {
|
|
86
73
|
delete requestQueue[url];
|
|
87
74
|
}
|
|
88
75
|
}
|
|
89
76
|
}, 0);
|
|
90
77
|
};
|
|
91
|
-
|
|
92
78
|
for (var i = 0, len = requestQueue[url].length; i < len; i++) {
|
|
93
79
|
_loop_1(i);
|
|
94
80
|
}
|
|
@@ -97,18 +83,15 @@ var processRequestQueue = function processRequestQueue(url) {
|
|
|
97
83
|
var loadSvgCached = function loadSvgCached(url, httpRequestWithCredentials, callback) {
|
|
98
84
|
if (cache.has(url)) {
|
|
99
85
|
var cacheValue = cache.get(url);
|
|
100
|
-
|
|
101
86
|
if (cacheValue === undefined) {
|
|
102
87
|
queueRequest(url, callback);
|
|
103
88
|
return;
|
|
104
89
|
}
|
|
105
|
-
|
|
106
90
|
if (cacheValue instanceof SVGSVGElement) {
|
|
107
91
|
callback(null, cloneSvg(cacheValue));
|
|
108
92
|
return;
|
|
109
93
|
}
|
|
110
94
|
}
|
|
111
|
-
|
|
112
95
|
cache.set(url, undefined);
|
|
113
96
|
queueRequest(url, callback);
|
|
114
97
|
makeAjaxRequest(url, httpRequestWithCredentials, function (error, httpRequest) {
|
|
@@ -117,7 +100,6 @@ var loadSvgCached = function loadSvgCached(url, httpRequestWithCredentials, call
|
|
|
117
100
|
} else if (httpRequest.responseXML instanceof Document && httpRequest.responseXML.documentElement && httpRequest.responseXML.documentElement instanceof SVGSVGElement) {
|
|
118
101
|
cache.set(url, httpRequest.responseXML.documentElement);
|
|
119
102
|
}
|
|
120
|
-
|
|
121
103
|
processRequestQueue(url);
|
|
122
104
|
});
|
|
123
105
|
};
|
|
@@ -133,7 +115,6 @@ var loadSvgUncached = function loadSvgUncached(url, httpRequestWithCredentials,
|
|
|
133
115
|
};
|
|
134
116
|
|
|
135
117
|
var idCounter = 0;
|
|
136
|
-
|
|
137
118
|
var uniqueId = function uniqueId() {
|
|
138
119
|
return ++idCounter;
|
|
139
120
|
};
|
|
@@ -142,21 +123,17 @@ var injectedElements = [];
|
|
|
142
123
|
var ranScripts = {};
|
|
143
124
|
var svgNamespace = 'http://www.w3.org/2000/svg';
|
|
144
125
|
var xlinkNamespace = 'http://www.w3.org/1999/xlink';
|
|
145
|
-
|
|
146
126
|
var injectElement = function injectElement(el, evalScripts, renumerateIRIElements, cacheRequests, httpRequestWithCredentials, beforeEach, callback) {
|
|
147
127
|
var elUrl = el.getAttribute('data-src') || el.getAttribute('src');
|
|
148
|
-
|
|
149
128
|
if (!elUrl) {
|
|
150
129
|
callback(new Error('Invalid data-src or src attribute'));
|
|
151
130
|
return;
|
|
152
131
|
}
|
|
153
|
-
|
|
154
132
|
if (injectedElements.indexOf(el) !== -1) {
|
|
155
133
|
injectedElements.splice(injectedElements.indexOf(el), 1);
|
|
156
134
|
el = null;
|
|
157
135
|
return;
|
|
158
136
|
}
|
|
159
|
-
|
|
160
137
|
injectedElements.push(el);
|
|
161
138
|
el.setAttribute('src', '');
|
|
162
139
|
var loadSvg = cacheRequests ? loadSvgCached : loadSvgUncached;
|
|
@@ -167,39 +144,28 @@ var injectElement = function injectElement(el, evalScripts, renumerateIRIElement
|
|
|
167
144
|
callback(error);
|
|
168
145
|
return;
|
|
169
146
|
}
|
|
170
|
-
|
|
171
147
|
var elId = el.getAttribute('id');
|
|
172
|
-
|
|
173
148
|
if (elId) {
|
|
174
149
|
svg.setAttribute('id', elId);
|
|
175
150
|
}
|
|
176
|
-
|
|
177
151
|
var elTitle = el.getAttribute('title');
|
|
178
|
-
|
|
179
152
|
if (elTitle) {
|
|
180
153
|
svg.setAttribute('title', elTitle);
|
|
181
154
|
}
|
|
182
|
-
|
|
183
155
|
var elWidth = el.getAttribute('width');
|
|
184
|
-
|
|
185
156
|
if (elWidth) {
|
|
186
157
|
svg.setAttribute('width', elWidth);
|
|
187
158
|
}
|
|
188
|
-
|
|
189
159
|
var elHeight = el.getAttribute('height');
|
|
190
|
-
|
|
191
160
|
if (elHeight) {
|
|
192
161
|
svg.setAttribute('height', elHeight);
|
|
193
162
|
}
|
|
194
|
-
|
|
195
163
|
var mergedClasses = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], (svg.getAttribute('class') || '').split(' '), true), ['injected-svg'], false), (el.getAttribute('class') || '').split(' '), true))).join(' ').trim();
|
|
196
164
|
svg.setAttribute('class', mergedClasses);
|
|
197
165
|
var elStyle = el.getAttribute('style');
|
|
198
|
-
|
|
199
166
|
if (elStyle) {
|
|
200
167
|
svg.setAttribute('style', elStyle);
|
|
201
168
|
}
|
|
202
|
-
|
|
203
169
|
svg.setAttribute('data-src', elUrl);
|
|
204
170
|
var elData = [].filter.call(el.attributes, function (at) {
|
|
205
171
|
return /^data-\w[\w-]*$/.test(at.name);
|
|
@@ -209,7 +175,6 @@ var injectElement = function injectElement(el, evalScripts, renumerateIRIElement
|
|
|
209
175
|
svg.setAttribute(dataAttr.name, dataAttr.value);
|
|
210
176
|
}
|
|
211
177
|
});
|
|
212
|
-
|
|
213
178
|
if (renumerateIRIElements) {
|
|
214
179
|
var iriElementsAndProperties_1 = {
|
|
215
180
|
clipPath: ['clip-path'],
|
|
@@ -232,76 +197,59 @@ var injectElement = function injectElement(el, evalScripts, renumerateIRIElement
|
|
|
232
197
|
element_1 = key;
|
|
233
198
|
properties_1 = iriElementsAndProperties_1[key];
|
|
234
199
|
elements_1 = svg.querySelectorAll(element_1 + '[id]');
|
|
235
|
-
|
|
236
200
|
var _loop_1 = function _loop_1(a, elementsLen) {
|
|
237
201
|
currentId_1 = elements_1[a].id;
|
|
238
202
|
newId_1 = currentId_1 + '-' + uniqueId();
|
|
239
203
|
var referencingElements;
|
|
240
204
|
Array.prototype.forEach.call(properties_1, function (property) {
|
|
241
205
|
referencingElements = svg.querySelectorAll('[' + property + '*="' + currentId_1 + '"]');
|
|
242
|
-
|
|
243
206
|
for (var b = 0, referencingElementLen = referencingElements.length; b < referencingElementLen; b++) {
|
|
244
207
|
var attrValue = referencingElements[b].getAttribute(property);
|
|
245
|
-
|
|
246
208
|
if (attrValue && !attrValue.match(new RegExp('url\\("?#' + currentId_1 + '"?\\)'))) {
|
|
247
209
|
continue;
|
|
248
210
|
}
|
|
249
|
-
|
|
250
211
|
referencingElements[b].setAttribute(property, 'url(#' + newId_1 + ')');
|
|
251
212
|
}
|
|
252
213
|
});
|
|
253
214
|
var allLinks = svg.querySelectorAll('[*|href]');
|
|
254
215
|
var links = [];
|
|
255
|
-
|
|
256
216
|
for (var c = 0, allLinksLen = allLinks.length; c < allLinksLen; c++) {
|
|
257
217
|
var href = allLinks[c].getAttributeNS(xlinkNamespace, 'href');
|
|
258
|
-
|
|
259
218
|
if (href && href.toString() === '#' + elements_1[a].id) {
|
|
260
219
|
links.push(allLinks[c]);
|
|
261
220
|
}
|
|
262
221
|
}
|
|
263
|
-
|
|
264
222
|
for (var d = 0, linksLen = links.length; d < linksLen; d++) {
|
|
265
223
|
links[d].setAttributeNS(xlinkNamespace, 'href', '#' + newId_1);
|
|
266
224
|
}
|
|
267
|
-
|
|
268
225
|
elements_1[a].id = newId_1;
|
|
269
226
|
};
|
|
270
|
-
|
|
271
227
|
for (var a = 0, elementsLen = elements_1.length; a < elementsLen; a++) {
|
|
272
228
|
_loop_1(a);
|
|
273
229
|
}
|
|
274
230
|
});
|
|
275
231
|
}
|
|
276
|
-
|
|
277
232
|
svg.removeAttribute('xmlns:a');
|
|
278
233
|
var scripts = svg.querySelectorAll('script');
|
|
279
234
|
var scriptsToEval = [];
|
|
280
235
|
var script;
|
|
281
236
|
var scriptType;
|
|
282
|
-
|
|
283
237
|
for (var i = 0, scriptsLen = scripts.length; i < scriptsLen; i++) {
|
|
284
238
|
scriptType = scripts[i].getAttribute('type');
|
|
285
|
-
|
|
286
239
|
if (!scriptType || scriptType === 'application/ecmascript' || scriptType === 'application/javascript' || scriptType === 'text/javascript') {
|
|
287
240
|
script = scripts[i].innerText || scripts[i].textContent;
|
|
288
|
-
|
|
289
241
|
if (script) {
|
|
290
242
|
scriptsToEval.push(script);
|
|
291
243
|
}
|
|
292
|
-
|
|
293
244
|
svg.removeChild(scripts[i]);
|
|
294
245
|
}
|
|
295
246
|
}
|
|
296
|
-
|
|
297
247
|
if (scriptsToEval.length > 0 && (evalScripts === 'always' || evalScripts === 'once' && !ranScripts[elUrl])) {
|
|
298
248
|
for (var l = 0, scriptsToEvalLen = scriptsToEval.length; l < scriptsToEvalLen; l++) {
|
|
299
249
|
new Function(scriptsToEval[l])(window);
|
|
300
250
|
}
|
|
301
|
-
|
|
302
251
|
ranScripts[elUrl] = true;
|
|
303
252
|
}
|
|
304
|
-
|
|
305
253
|
var styleTags = svg.querySelectorAll('style');
|
|
306
254
|
Array.prototype.forEach.call(styleTags, function (styleTag) {
|
|
307
255
|
styleTag.textContent += '';
|
|
@@ -309,14 +257,12 @@ var injectElement = function injectElement(el, evalScripts, renumerateIRIElement
|
|
|
309
257
|
svg.setAttribute('xmlns', svgNamespace);
|
|
310
258
|
svg.setAttribute('xmlns:xlink', xlinkNamespace);
|
|
311
259
|
beforeEach(svg);
|
|
312
|
-
|
|
313
260
|
if (!el.parentNode) {
|
|
314
261
|
injectedElements.splice(injectedElements.indexOf(el), 1);
|
|
315
262
|
el = null;
|
|
316
263
|
callback(new Error('Parent node is null'));
|
|
317
264
|
return;
|
|
318
265
|
}
|
|
319
|
-
|
|
320
266
|
el.parentNode.replaceChild(svg, el);
|
|
321
267
|
injectedElements.splice(injectedElements.indexOf(el), 1);
|
|
322
268
|
el = null;
|
|
@@ -326,34 +272,31 @@ var injectElement = function injectElement(el, evalScripts, renumerateIRIElement
|
|
|
326
272
|
|
|
327
273
|
var SVGInjector = function SVGInjector(elements, _a) {
|
|
328
274
|
var _b = _a === void 0 ? {} : _a,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
275
|
+
_c = _b.afterAll,
|
|
276
|
+
afterAll = _c === void 0 ? function () {
|
|
277
|
+
return undefined;
|
|
278
|
+
} : _c,
|
|
279
|
+
_d = _b.afterEach,
|
|
280
|
+
afterEach = _d === void 0 ? function () {
|
|
281
|
+
return undefined;
|
|
282
|
+
} : _d,
|
|
283
|
+
_e = _b.beforeEach,
|
|
284
|
+
beforeEach = _e === void 0 ? function () {
|
|
285
|
+
return undefined;
|
|
286
|
+
} : _e,
|
|
287
|
+
_f = _b.cacheRequests,
|
|
288
|
+
cacheRequests = _f === void 0 ? true : _f,
|
|
289
|
+
_g = _b.evalScripts,
|
|
290
|
+
evalScripts = _g === void 0 ? 'never' : _g,
|
|
291
|
+
_h = _b.httpRequestWithCredentials,
|
|
292
|
+
httpRequestWithCredentials = _h === void 0 ? false : _h,
|
|
293
|
+
_j = _b.renumerateIRIElements,
|
|
294
|
+
renumerateIRIElements = _j === void 0 ? true : _j;
|
|
350
295
|
if (elements && 'length' in elements) {
|
|
351
296
|
var elementsLoaded_1 = 0;
|
|
352
|
-
|
|
353
297
|
for (var i = 0, j = elements.length; i < j; i++) {
|
|
354
298
|
injectElement(elements[i], evalScripts, renumerateIRIElements, cacheRequests, httpRequestWithCredentials, beforeEach, function (error, svg) {
|
|
355
299
|
afterEach(error, svg);
|
|
356
|
-
|
|
357
300
|
if (elements && 'length' in elements && elements.length === ++elementsLoaded_1) {
|
|
358
301
|
afterAll(elementsLoaded_1);
|
|
359
302
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg-injector.esm.js","sources":["../src/cache.ts","../src/clone-svg.ts","../src/is-local.ts","../src/make-ajax-request.ts","../src/request-queue.ts","../src/load-svg-cached.ts","../src/load-svg-uncached.ts","../src/unique-id.ts","../src/inject-element.ts","../src/svg-injector.ts"],"sourcesContent":["const cache = new Map<string, SVGSVGElement | Error | undefined>()\n\nexport default cache\n","const cloneSvg = (sourceSvg: SVGSVGElement) =>\n sourceSvg.cloneNode(true) as SVGSVGElement\n\nexport default cloneSvg\n","const isLocal = () => window.location.protocol === 'file:'\n\nexport default isLocal\n","import { parse as parseContentType } from 'content-type'\nimport isLocal from './is-local'\n\nconst makeAjaxRequest = (\n url: string,\n httpRequestWithCredentials: boolean,\n callback: (error: Error | null, httpRequest: XMLHttpRequest) => void\n) => {\n const httpRequest = new XMLHttpRequest()\n\n httpRequest.onreadystatechange = () => {\n try {\n if (!/\\.svg/i.test(url) && httpRequest.readyState === 2) {\n const contentType = httpRequest.getResponseHeader('Content-Type')\n if (!contentType) {\n throw new Error('Content type not found')\n }\n\n const { type } = parseContentType(contentType)\n if (!(type === 'image/svg+xml' || type === 'text/plain')) {\n throw new Error(`Invalid content type: ${type}`)\n }\n }\n\n if (httpRequest.readyState === 4) {\n if (httpRequest.status === 404 || httpRequest.responseXML === null) {\n throw new Error(\n isLocal()\n ? 'Note: SVG injection ajax calls do not work locally without ' +\n 'adjusting security settings in your browser. Or consider ' +\n 'using a local webserver.'\n : 'Unable to load SVG file: ' + url\n )\n }\n\n if (\n httpRequest.status === 200 ||\n (isLocal() && httpRequest.status === 0)\n ) {\n callback(null, httpRequest)\n } else {\n throw new Error(\n 'There was a problem injecting the SVG: ' +\n httpRequest.status +\n ' ' +\n httpRequest.statusText\n )\n }\n }\n } catch (error) {\n httpRequest.abort()\n if (error instanceof Error) {\n callback(error, httpRequest)\n } else {\n throw error\n }\n }\n }\n\n httpRequest.open('GET', url)\n\n httpRequest.withCredentials = httpRequestWithCredentials\n\n /* istanbul ignore else */\n if (httpRequest.overrideMimeType) {\n httpRequest.overrideMimeType('text/xml')\n }\n\n httpRequest.send()\n}\n\nexport default makeAjaxRequest\n","import cache from './cache'\nimport cloneSvg from './clone-svg'\nimport { Errback } from './types'\n\nlet requestQueue: { [key: string]: Errback[] } = {}\n\nexport const clear = () => {\n requestQueue = {}\n}\n\nexport const queueRequest = (url: string, callback: Errback) => {\n requestQueue[url] = requestQueue[url] || []\n requestQueue[url].push(callback)\n}\n\nexport const processRequestQueue = (url: string) => {\n for (let i = 0, len = requestQueue[url].length; i < len; i++) {\n // Make these calls async so we avoid blocking the page/renderer.\n setTimeout(() => {\n /* istanbul ignore else */\n if (Array.isArray(requestQueue[url])) {\n const cacheValue = cache.get(url)\n const callback = requestQueue[url][i]\n\n /* istanbul ignore else */\n if (cacheValue instanceof SVGSVGElement) {\n callback(null, cloneSvg(cacheValue))\n }\n\n /* istanbul ignore else */\n if (cacheValue instanceof Error) {\n callback(cacheValue)\n }\n\n /* istanbul ignore else */\n if (i === requestQueue[url].length - 1) {\n delete requestQueue[url]\n }\n }\n }, 0)\n }\n}\n","import cache from './cache'\nimport cloneSvg from './clone-svg'\nimport makeAjaxRequest from './make-ajax-request'\nimport { processRequestQueue, queueRequest } from './request-queue'\nimport { Errback } from './types'\n\nconst loadSvgCached = (\n url: string,\n httpRequestWithCredentials: boolean,\n callback: Errback\n) => {\n if (cache.has(url)) {\n const cacheValue = cache.get(url)\n\n if (cacheValue === undefined) {\n queueRequest(url, callback)\n return\n }\n\n /* istanbul ignore else */\n if (cacheValue instanceof SVGSVGElement) {\n callback(null, cloneSvg(cacheValue))\n return\n }\n\n // Errors are always refetched.\n }\n\n // Seed the cache to indicate we are loading this URL.\n cache.set(url, undefined)\n queueRequest(url, callback)\n\n makeAjaxRequest(url, httpRequestWithCredentials, (error, httpRequest) => {\n /* istanbul ignore else */\n if (error) {\n cache.set(url, error)\n } else if (\n httpRequest.responseXML instanceof Document &&\n httpRequest.responseXML.documentElement &&\n httpRequest.responseXML.documentElement instanceof SVGSVGElement\n ) {\n cache.set(url, httpRequest.responseXML.documentElement)\n }\n processRequestQueue(url)\n })\n}\n\nexport default loadSvgCached\n","import makeAjaxRequest from './make-ajax-request'\nimport { Errback } from './types'\n\nconst loadSvgUncached = (\n url: string,\n httpRequestWithCredentials: boolean,\n callback: Errback\n) => {\n makeAjaxRequest(url, httpRequestWithCredentials, (error, httpRequest) => {\n /* istanbul ignore else */\n if (error) {\n callback(error)\n } else if (\n httpRequest.responseXML instanceof Document &&\n httpRequest.responseXML.documentElement &&\n httpRequest.responseXML.documentElement instanceof SVGSVGElement\n ) {\n callback(null, httpRequest.responseXML.documentElement)\n }\n })\n}\n\nexport default loadSvgUncached\n","let idCounter = 0\nconst uniqueId = () => ++idCounter\nexport default uniqueId\n","import loadSvgCached from './load-svg-cached'\nimport loadSvgUncached from './load-svg-uncached'\nimport { BeforeEach, Errback, EvalScripts } from './types'\nimport uniqueId from './unique-id'\n\ntype ElementType = Element | HTMLElement | null\n\nconst injectedElements: ElementType[] = []\nconst ranScripts: { [key: string]: boolean } = {}\nconst svgNamespace = 'http://www.w3.org/2000/svg'\nconst xlinkNamespace = 'http://www.w3.org/1999/xlink'\n\nconst injectElement = (\n el: NonNullable<ElementType>,\n evalScripts: EvalScripts,\n renumerateIRIElements: boolean,\n cacheRequests: boolean,\n httpRequestWithCredentials: boolean,\n beforeEach: BeforeEach,\n callback: Errback\n) => {\n const elUrl = el.getAttribute('data-src') || el.getAttribute('src')\n\n /* istanbul ignore else */\n if (!elUrl) {\n callback(new Error('Invalid data-src or src attribute'))\n return\n }\n\n // Make sure we aren't already in the process of injecting this element to\n // avoid a race condition if multiple injections for the same element are run.\n // :NOTE: Using indexOf() only _after_ we check for SVG support and bail, so\n // no need for IE8 indexOf() polyfill.\n /* istanbul ignore else */\n if (injectedElements.indexOf(el) !== -1) {\n // TODO: Extract.\n injectedElements.splice(injectedElements.indexOf(el), 1)\n ;(el as ElementType) = null\n return\n }\n\n // Remember the request to inject this element, in case other injection calls\n // are also trying to replace this element before we finish.\n injectedElements.push(el)\n\n // Try to avoid loading the orginal image src if possible.\n el.setAttribute('src', '')\n\n const loadSvg = cacheRequests ? loadSvgCached : loadSvgUncached\n\n loadSvg(elUrl, httpRequestWithCredentials, (error, svg) => {\n /* istanbul ignore else */\n if (!svg) {\n // TODO: Extract.\n injectedElements.splice(injectedElements.indexOf(el), 1)\n ;(el as ElementType) = null\n callback(error)\n return\n }\n\n const elId = el.getAttribute('id')\n /* istanbul ignore else */\n if (elId) {\n svg.setAttribute('id', elId)\n }\n\n const elTitle = el.getAttribute('title')\n /* istanbul ignore else */\n if (elTitle) {\n svg.setAttribute('title', elTitle)\n }\n\n const elWidth = el.getAttribute('width')\n /* istanbul ignore else */\n if (elWidth) {\n svg.setAttribute('width', elWidth)\n }\n\n const elHeight = el.getAttribute('height')\n /* istanbul ignore else */\n if (elHeight) {\n svg.setAttribute('height', elHeight)\n }\n\n const mergedClasses = Array.from(\n new Set([\n ...(svg.getAttribute('class') || '').split(' '),\n 'injected-svg',\n ...(el.getAttribute('class') || '').split(' '),\n ])\n )\n .join(' ')\n .trim()\n svg.setAttribute('class', mergedClasses)\n\n const elStyle = el.getAttribute('style')\n /* istanbul ignore else */\n if (elStyle) {\n svg.setAttribute('style', elStyle)\n }\n\n svg.setAttribute('data-src', elUrl)\n\n // Copy all the data elements to the svg.\n const elData = [].filter.call(el.attributes, (at: Attr) => {\n return /^data-\\w[\\w-]*$/.test(at.name)\n })\n\n Array.prototype.forEach.call(elData, (dataAttr: Attr) => {\n /* istanbul ignore else */\n if (dataAttr.name && dataAttr.value) {\n svg.setAttribute(dataAttr.name, dataAttr.value)\n }\n })\n\n /* istanbul ignore else */\n if (renumerateIRIElements) {\n // Make sure any internally referenced clipPath ids and their clip-path\n // references are unique.\n //\n // This addresses the issue of having multiple instances of the same SVG\n // on a page and only the first clipPath id is referenced.\n //\n // Browsers often shortcut the SVG Spec and don't use clipPaths contained\n // in parent elements that are hidden, so if you hide the first SVG\n // instance on the page, then all other instances lose their clipping.\n // Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=376027\n\n // Handle all defs elements that have iri capable attributes as defined by\n // w3c: http://www.w3.org/TR/SVG/linking.html#processingIRI. Mapping IRI\n // addressable elements to the properties that can reference them.\n const iriElementsAndProperties: { [key: string]: string[] } = {\n clipPath: ['clip-path'],\n 'color-profile': ['color-profile'],\n cursor: ['cursor'],\n filter: ['filter'],\n linearGradient: ['fill', 'stroke'],\n marker: ['marker', 'marker-start', 'marker-mid', 'marker-end'],\n mask: ['mask'],\n path: [],\n pattern: ['fill', 'stroke'],\n radialGradient: ['fill', 'stroke'],\n }\n\n let element\n let elements\n let properties\n let currentId: string\n let newId: string\n\n Object.keys(iriElementsAndProperties).forEach((key) => {\n element = key\n properties = iriElementsAndProperties[key]\n\n elements = svg.querySelectorAll(element + '[id]')\n for (let a = 0, elementsLen = elements.length; a < elementsLen; a++) {\n currentId = elements[a].id\n newId = currentId + '-' + uniqueId()\n\n // All of the properties that can reference this element type.\n let referencingElements\n Array.prototype.forEach.call(properties, (property: string) => {\n // :NOTE: using a substring match attr selector here to deal with IE\n // \"adding extra quotes in url() attrs\".\n referencingElements = svg.querySelectorAll(\n '[' + property + '*=\"' + currentId + '\"]'\n )\n for (\n let b = 0, referencingElementLen = referencingElements.length;\n b < referencingElementLen;\n b++\n ) {\n const attrValue: string | null =\n referencingElements[b].getAttribute(property)\n if (\n attrValue &&\n !attrValue.match(new RegExp('url\\\\(\"?#' + currentId + '\"?\\\\)'))\n ) {\n continue\n }\n referencingElements[b].setAttribute(\n property,\n 'url(#' + newId + ')'\n )\n }\n })\n\n const allLinks = svg.querySelectorAll('[*|href]')\n const links = []\n for (let c = 0, allLinksLen = allLinks.length; c < allLinksLen; c++) {\n const href = allLinks[c].getAttributeNS(xlinkNamespace, 'href')\n /* istanbul ignore else */\n if (href && href.toString() === '#' + elements[a].id) {\n links.push(allLinks[c])\n }\n }\n for (let d = 0, linksLen = links.length; d < linksLen; d++) {\n links[d].setAttributeNS(xlinkNamespace, 'href', '#' + newId)\n }\n\n elements[a].id = newId\n }\n })\n }\n\n // Remove any unwanted/invalid namespaces that might have been added by SVG\n // editing tools.\n svg.removeAttribute('xmlns:a')\n\n // Post page load injected SVGs don't automatically have their script\n // elements run, so we'll need to make that happen, if requested.\n\n // Find then prune the scripts.\n const scripts = svg.querySelectorAll('script')\n const scriptsToEval: string[] = []\n let script\n let scriptType\n\n for (let i = 0, scriptsLen = scripts.length; i < scriptsLen; i++) {\n scriptType = scripts[i].getAttribute('type')\n\n // Only process javascript types. SVG defaults to 'application/ecmascript'\n // for unset types.\n /* istanbul ignore else */\n if (\n !scriptType ||\n scriptType === 'application/ecmascript' ||\n scriptType === 'application/javascript' ||\n scriptType === 'text/javascript'\n ) {\n // innerText for IE, textContent for other browsers.\n script = scripts[i].innerText || scripts[i].textContent\n\n // Stash.\n /* istanbul ignore else */\n if (script) {\n scriptsToEval.push(script)\n }\n\n // Tidy up and remove the script element since we don't need it anymore.\n svg.removeChild(scripts[i])\n }\n }\n\n // Run/Eval the scripts if needed.\n /* istanbul ignore else */\n if (\n scriptsToEval.length > 0 &&\n (evalScripts === 'always' ||\n (evalScripts === 'once' && !ranScripts[elUrl]))\n ) {\n for (\n let l = 0, scriptsToEvalLen = scriptsToEval.length;\n l < scriptsToEvalLen;\n l++\n ) {\n // :NOTE: Yup, this is a form of eval, but it is being used to eval code\n // the caller has explictely asked to be loaded, and the code is in a\n // caller defined SVG file... not raw user input.\n //\n // Also, the code is evaluated in a closure and not in the global scope.\n // If you need to put something in global scope, use 'window'.\n new Function(scriptsToEval[l])(window)\n }\n\n // Remember we already ran scripts for this svg.\n ranScripts[elUrl] = true\n }\n\n // :WORKAROUND: IE doesn't evaluate <style> tags in SVGs that are\n // dynamically added to the page. This trick will trigger IE to read and use\n // any existing SVG <style> tags.\n //\n // Reference: https://github.com/iconic/SVGInjector/issues/23.\n const styleTags = svg.querySelectorAll('style')\n Array.prototype.forEach.call(styleTags, (styleTag: HTMLStyleElement) => {\n styleTag.textContent += ''\n })\n\n svg.setAttribute('xmlns', svgNamespace)\n svg.setAttribute('xmlns:xlink', xlinkNamespace)\n\n beforeEach(svg)\n\n if (!el.parentNode) {\n injectedElements.splice(injectedElements.indexOf(el), 1)\n ;(el as ElementType) = null\n callback(new Error('Parent node is null'))\n return\n }\n\n // Replace the image with the svg.\n el.parentNode.replaceChild(svg, el)\n\n // Now that we no longer need it, drop references to the original element so\n // it can be GC'd.\n // TODO: Extract\n injectedElements.splice(injectedElements.indexOf(el), 1)\n ;(el as ElementType) = null\n\n callback(null, svg)\n })\n}\n\nexport default injectElement\n","import injectElement from './inject-element'\nimport { AfterAll, BeforeEach, Errback, EvalScripts } from './types'\n\ntype Elements = HTMLCollectionOf<Element> | NodeListOf<Element> | Element | null\n\ninterface OptionalArgs {\n afterAll?: AfterAll\n afterEach?: Errback\n beforeEach?: BeforeEach\n cacheRequests?: boolean\n evalScripts?: EvalScripts\n httpRequestWithCredentials?: boolean\n renumerateIRIElements?: boolean\n}\n\nconst SVGInjector = (\n elements: Elements,\n {\n afterAll = () => undefined,\n afterEach = () => undefined,\n beforeEach = () => undefined,\n cacheRequests = true,\n evalScripts = 'never',\n httpRequestWithCredentials = false,\n renumerateIRIElements = true,\n }: OptionalArgs = {}\n) => {\n if (elements && 'length' in elements) {\n let elementsLoaded = 0\n for (let i = 0, j = elements.length; i < j; i++) {\n injectElement(\n elements[i],\n evalScripts,\n renumerateIRIElements,\n cacheRequests,\n httpRequestWithCredentials,\n beforeEach,\n (error, svg) => {\n afterEach(error, svg)\n if (\n elements &&\n 'length' in elements &&\n elements.length === ++elementsLoaded\n ) {\n afterAll(elementsLoaded)\n }\n }\n )\n }\n } else if (elements) {\n injectElement(\n elements,\n evalScripts,\n renumerateIRIElements,\n cacheRequests,\n httpRequestWithCredentials,\n beforeEach,\n (error, svg) => {\n afterEach(error, svg)\n afterAll(1)\n elements = null\n }\n )\n } else {\n afterAll(0)\n }\n}\n\nexport default SVGInjector\n"],"names":["cache","Map","cloneSvg","sourceSvg","cloneNode","isLocal","location","protocol","makeAjaxRequest","callback","httpRequest","onreadystatechange","test","url","readyState","contentType","Error","parseContentType","type","status","responseXML","statusText","error","abort","requestQueue","queueRequest","push","len","setTimeout","cacheValue","get","i","SVGSVGElement","length","httpRequestWithCredentials","has","undefined","set","loadSvgUncached","Document","idCounter","uniqueId","injectedElements","ranScripts","svgNamespace","xlinkNamespace","el","renumerateIRIElements","beforeEach","elUrl","getAttribute","indexOf","splice","cacheRequests","loadSvgCached","loadSvg","svg","elId","setAttribute","elTitle","elWidth","elHeight","mergedClasses","Array","from","split","join","trim","elStyle","elData","filter","call","attributes","at","name","prototype","forEach","dataAttr","value","iriElementsAndProperties_1","clipPath","linearGradient","marker","pattern","element_1","elements_1","properties_1","currentId_1","newId_1","Object","keys","key","querySelectorAll","a","elementsLen","id","property","referencingElements","SVGInjector","elements","_a","_b","_c","afterAll","_d","_e","_f","_g","evalScripts","_h","_j"],"mappings":";;;AAAA,IAAWA,KAAA,GAAO,IAAAC,GAAA,EAAlB;;ACAA,IAAMC,QAAW,GAAA,SAAXA,QAAW,CAAAC,SAAA,EAAyB;EACxC,OAAA,SAAA,CAASC,SAAT,CAAmB,IAAnB,CAAA,CAAA;AAA0C,CAD5C;;ACAA,IAAaC,OAAA,GAAS,SAATA,OAAS,GAAA;AAAA,EAAA,OAAA,MAAA,CAAAC,QAAA,CAAMC,QAAN,KAAgB,OAAhB,CAAA;AAAwB,CAA9C;;ACQE,IAAAC,eAAiB,GAAO,SAAxBA,eAAwB,IAAA,4BAAA,EAIpBC,QAJoB,EAIqC;iBAEnD;;EAEHC,WAAA,CAAAC,kBAAA,GAAA,YAAA;IAEO,IAAA;oBACJC,KAAEC,QAASH,WAAA,CAAAI,UAAA,KAAwC,GAAA;AACrD,QAAA,IAAAC,WAAA,gDAAA,CAAA;;QACD,IAAA,CAAAA,WAAA,EAAA;AACF,UAAA,MAAA,IAAAC,KAAA,CAAA,wBAAA,CAAA,CAAA;AAED,SAAA;;AAEI,QAAA,IAAA,IAAA,GAAAC,KACE,CAAAF,WAAA,CADF,CACWG,IADX,CAAA;;QAEI,IAAA,EAAAA,IAAA,KAAA,eAAA,IAA+DA,IAAA,KAAA,YAA/D,CAAA,EAA+D;kDACFA,CAAAA,MAAAA,CAAAA;;AAE7D,OAAA;;AAIN,MAAA,IAAAR,WACa,CAAAI,UADb,KACoB,CADpB,EACoB;uBACjB,CAAAK,WAAa,OAAAT,WAAkB,CAAAU,WAAlB,KACd,MAAA;AACA,UAAA,MAAA,IAAAJ,KAAA,CACDX,OAAA,EAAM,GAAA,6DAAA,8DAAA,GAGD,0BAHL,8BAIQQ,GAAAA,GALP,CAAA,CAAA;AAQD,SAAA;;AAEJ,Q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A,EAAAA,GAAAA,EAAAA,CAAAA,0BAAAA;MAAA3E,0BAAA,GAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,GAAA2E,EAAAA;;2BACM,GAAA,EAAA,KAAA,KAAA,CAAA,GAAA,IAAA,GAAAC,EAAAA,CAAAA;;AAIf,EAAA,IAAAX,QAAA,YAA0BA,IAAAA,QAA1B,EAA0B;;;;;;;;;;;;GAA1B;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"svg-injector.esm.js","sources":["../src/cache.ts","../src/clone-svg.ts","../src/is-local.ts","../src/make-ajax-request.ts","../src/request-queue.ts","../src/load-svg-cached.ts","../src/load-svg-uncached.ts","../src/unique-id.ts","../src/inject-element.ts","../src/svg-injector.ts"],"sourcesContent":["const cache = new Map<string, SVGSVGElement | Error | undefined>()\n\nexport default cache\n","const cloneSvg = (sourceSvg: SVGSVGElement) =>\n sourceSvg.cloneNode(true) as SVGSVGElement\n\nexport default cloneSvg\n","const isLocal = () => window.location.protocol === 'file:'\n\nexport default isLocal\n","import { parse as parseContentType } from 'content-type'\nimport isLocal from './is-local'\n\nconst makeAjaxRequest = (\n url: string,\n httpRequestWithCredentials: boolean,\n callback: (error: Error | null, httpRequest: XMLHttpRequest) => void\n) => {\n const httpRequest = new XMLHttpRequest()\n\n httpRequest.onreadystatechange = () => {\n try {\n if (!/\\.svg/i.test(url) && httpRequest.readyState === 2) {\n const contentType = httpRequest.getResponseHeader('Content-Type')\n if (!contentType) {\n throw new Error('Content type not found')\n }\n\n const { type } = parseContentType(contentType)\n if (!(type === 'image/svg+xml' || type === 'text/plain')) {\n throw new Error(`Invalid content type: ${type}`)\n }\n }\n\n if (httpRequest.readyState === 4) {\n if (httpRequest.status === 404 || httpRequest.responseXML === null) {\n throw new Error(\n isLocal()\n ? 'Note: SVG injection ajax calls do not work locally without ' +\n 'adjusting security settings in your browser. Or consider ' +\n 'using a local webserver.'\n : 'Unable to load SVG file: ' + url\n )\n }\n\n if (\n httpRequest.status === 200 ||\n (isLocal() && httpRequest.status === 0)\n ) {\n callback(null, httpRequest)\n } else {\n throw new Error(\n 'There was a problem injecting the SVG: ' +\n httpRequest.status +\n ' ' +\n httpRequest.statusText\n )\n }\n }\n } catch (error) {\n httpRequest.abort()\n if (error instanceof Error) {\n callback(error, httpRequest)\n } else {\n throw error\n }\n }\n }\n\n httpRequest.open('GET', url)\n\n httpRequest.withCredentials = httpRequestWithCredentials\n\n /* istanbul ignore else */\n if (httpRequest.overrideMimeType) {\n httpRequest.overrideMimeType('text/xml')\n }\n\n httpRequest.send()\n}\n\nexport default makeAjaxRequest\n","import cache from './cache'\nimport cloneSvg from './clone-svg'\nimport { Errback } from './types'\n\nlet requestQueue: { [key: string]: Errback[] } = {}\n\nexport const clear = () => {\n requestQueue = {}\n}\n\nexport const queueRequest = (url: string, callback: Errback) => {\n requestQueue[url] = requestQueue[url] || []\n requestQueue[url].push(callback)\n}\n\nexport const processRequestQueue = (url: string) => {\n for (let i = 0, len = requestQueue[url].length; i < len; i++) {\n // Make these calls async so we avoid blocking the page/renderer.\n setTimeout(() => {\n /* istanbul ignore else */\n if (Array.isArray(requestQueue[url])) {\n const cacheValue = cache.get(url)\n const callback = requestQueue[url][i]\n\n /* istanbul ignore else */\n if (cacheValue instanceof SVGSVGElement) {\n callback(null, cloneSvg(cacheValue))\n }\n\n /* istanbul ignore else */\n if (cacheValue instanceof Error) {\n callback(cacheValue)\n }\n\n /* istanbul ignore else */\n if (i === requestQueue[url].length - 1) {\n delete requestQueue[url]\n }\n }\n }, 0)\n }\n}\n","import cache from './cache'\nimport cloneSvg from './clone-svg'\nimport makeAjaxRequest from './make-ajax-request'\nimport { processRequestQueue, queueRequest } from './request-queue'\nimport { Errback } from './types'\n\nconst loadSvgCached = (\n url: string,\n httpRequestWithCredentials: boolean,\n callback: Errback\n) => {\n if (cache.has(url)) {\n const cacheValue = cache.get(url)\n\n if (cacheValue === undefined) {\n queueRequest(url, callback)\n return\n }\n\n /* istanbul ignore else */\n if (cacheValue instanceof SVGSVGElement) {\n callback(null, cloneSvg(cacheValue))\n return\n }\n\n // Errors are always refetched.\n }\n\n // Seed the cache to indicate we are loading this URL.\n cache.set(url, undefined)\n queueRequest(url, callback)\n\n makeAjaxRequest(url, httpRequestWithCredentials, (error, httpRequest) => {\n /* istanbul ignore else */\n if (error) {\n cache.set(url, error)\n } else if (\n httpRequest.responseXML instanceof Document &&\n httpRequest.responseXML.documentElement &&\n httpRequest.responseXML.documentElement instanceof SVGSVGElement\n ) {\n cache.set(url, httpRequest.responseXML.documentElement)\n }\n processRequestQueue(url)\n })\n}\n\nexport default loadSvgCached\n","import makeAjaxRequest from './make-ajax-request'\nimport { Errback } from './types'\n\nconst loadSvgUncached = (\n url: string,\n httpRequestWithCredentials: boolean,\n callback: Errback\n) => {\n makeAjaxRequest(url, httpRequestWithCredentials, (error, httpRequest) => {\n /* istanbul ignore else */\n if (error) {\n callback(error)\n } else if (\n httpRequest.responseXML instanceof Document &&\n httpRequest.responseXML.documentElement &&\n httpRequest.responseXML.documentElement instanceof SVGSVGElement\n ) {\n callback(null, httpRequest.responseXML.documentElement)\n }\n })\n}\n\nexport default loadSvgUncached\n","let idCounter = 0\nconst uniqueId = () => ++idCounter\nexport default uniqueId\n","import loadSvgCached from './load-svg-cached'\nimport loadSvgUncached from './load-svg-uncached'\nimport { BeforeEach, Errback, EvalScripts } from './types'\nimport uniqueId from './unique-id'\n\ntype ElementType = Element | HTMLElement | null\n\nconst injectedElements: ElementType[] = []\nconst ranScripts: { [key: string]: boolean } = {}\nconst svgNamespace = 'http://www.w3.org/2000/svg'\nconst xlinkNamespace = 'http://www.w3.org/1999/xlink'\n\nconst injectElement = (\n el: NonNullable<ElementType>,\n evalScripts: EvalScripts,\n renumerateIRIElements: boolean,\n cacheRequests: boolean,\n httpRequestWithCredentials: boolean,\n beforeEach: BeforeEach,\n callback: Errback\n) => {\n const elUrl = el.getAttribute('data-src') || el.getAttribute('src')\n\n /* istanbul ignore else */\n if (!elUrl) {\n callback(new Error('Invalid data-src or src attribute'))\n return\n }\n\n // Make sure we aren't already in the process of injecting this element to\n // avoid a race condition if multiple injections for the same element are run.\n // :NOTE: Using indexOf() only _after_ we check for SVG support and bail, so\n // no need for IE8 indexOf() polyfill.\n /* istanbul ignore else */\n if (injectedElements.indexOf(el) !== -1) {\n // TODO: Extract.\n injectedElements.splice(injectedElements.indexOf(el), 1)\n ;(el as ElementType) = null\n return\n }\n\n // Remember the request to inject this element, in case other injection calls\n // are also trying to replace this element before we finish.\n injectedElements.push(el)\n\n // Try to avoid loading the orginal image src if possible.\n el.setAttribute('src', '')\n\n const loadSvg = cacheRequests ? loadSvgCached : loadSvgUncached\n\n loadSvg(elUrl, httpRequestWithCredentials, (error, svg) => {\n /* istanbul ignore else */\n if (!svg) {\n // TODO: Extract.\n injectedElements.splice(injectedElements.indexOf(el), 1)\n ;(el as ElementType) = null\n callback(error)\n return\n }\n\n const elId = el.getAttribute('id')\n /* istanbul ignore else */\n if (elId) {\n svg.setAttribute('id', elId)\n }\n\n const elTitle = el.getAttribute('title')\n /* istanbul ignore else */\n if (elTitle) {\n svg.setAttribute('title', elTitle)\n }\n\n const elWidth = el.getAttribute('width')\n /* istanbul ignore else */\n if (elWidth) {\n svg.setAttribute('width', elWidth)\n }\n\n const elHeight = el.getAttribute('height')\n /* istanbul ignore else */\n if (elHeight) {\n svg.setAttribute('height', elHeight)\n }\n\n const mergedClasses = Array.from(\n new Set([\n ...(svg.getAttribute('class') || '').split(' '),\n 'injected-svg',\n ...(el.getAttribute('class') || '').split(' '),\n ])\n )\n .join(' ')\n .trim()\n svg.setAttribute('class', mergedClasses)\n\n const elStyle = el.getAttribute('style')\n /* istanbul ignore else */\n if (elStyle) {\n svg.setAttribute('style', elStyle)\n }\n\n svg.setAttribute('data-src', elUrl)\n\n // Copy all the data elements to the svg.\n const elData = [].filter.call(el.attributes, (at: Attr) => {\n return /^data-\\w[\\w-]*$/.test(at.name)\n })\n\n Array.prototype.forEach.call(elData, (dataAttr: Attr) => {\n /* istanbul ignore else */\n if (dataAttr.name && dataAttr.value) {\n svg.setAttribute(dataAttr.name, dataAttr.value)\n }\n })\n\n /* istanbul ignore else */\n if (renumerateIRIElements) {\n // Make sure any internally referenced clipPath ids and their clip-path\n // references are unique.\n //\n // This addresses the issue of having multiple instances of the same SVG\n // on a page and only the first clipPath id is referenced.\n //\n // Browsers often shortcut the SVG Spec and don't use clipPaths contained\n // in parent elements that are hidden, so if you hide the first SVG\n // instance on the page, then all other instances lose their clipping.\n // Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=376027\n\n // Handle all defs elements that have iri capable attributes as defined by\n // w3c: http://www.w3.org/TR/SVG/linking.html#processingIRI. Mapping IRI\n // addressable elements to the properties that can reference them.\n const iriElementsAndProperties: { [key: string]: string[] } = {\n clipPath: ['clip-path'],\n 'color-profile': ['color-profile'],\n cursor: ['cursor'],\n filter: ['filter'],\n linearGradient: ['fill', 'stroke'],\n marker: ['marker', 'marker-start', 'marker-mid', 'marker-end'],\n mask: ['mask'],\n path: [],\n pattern: ['fill', 'stroke'],\n radialGradient: ['fill', 'stroke'],\n }\n\n let element\n let elements\n let properties\n let currentId: string\n let newId: string\n\n Object.keys(iriElementsAndProperties).forEach((key) => {\n element = key\n properties = iriElementsAndProperties[key]\n\n elements = svg.querySelectorAll(element + '[id]')\n for (let a = 0, elementsLen = elements.length; a < elementsLen; a++) {\n currentId = elements[a].id\n newId = currentId + '-' + uniqueId()\n\n // All of the properties that can reference this element type.\n let referencingElements\n Array.prototype.forEach.call(properties, (property: string) => {\n // :NOTE: using a substring match attr selector here to deal with IE\n // \"adding extra quotes in url() attrs\".\n referencingElements = svg.querySelectorAll(\n '[' + property + '*=\"' + currentId + '\"]'\n )\n for (\n let b = 0, referencingElementLen = referencingElements.length;\n b < referencingElementLen;\n b++\n ) {\n const attrValue: string | null =\n referencingElements[b].getAttribute(property)\n if (\n attrValue &&\n !attrValue.match(new RegExp('url\\\\(\"?#' + currentId + '\"?\\\\)'))\n ) {\n continue\n }\n referencingElements[b].setAttribute(\n property,\n 'url(#' + newId + ')'\n )\n }\n })\n\n const allLinks = svg.querySelectorAll('[*|href]')\n const links = []\n for (let c = 0, allLinksLen = allLinks.length; c < allLinksLen; c++) {\n const href = allLinks[c].getAttributeNS(xlinkNamespace, 'href')\n /* istanbul ignore else */\n if (href && href.toString() === '#' + elements[a].id) {\n links.push(allLinks[c])\n }\n }\n for (let d = 0, linksLen = links.length; d < linksLen; d++) {\n links[d].setAttributeNS(xlinkNamespace, 'href', '#' + newId)\n }\n\n elements[a].id = newId\n }\n })\n }\n\n // Remove any unwanted/invalid namespaces that might have been added by SVG\n // editing tools.\n svg.removeAttribute('xmlns:a')\n\n // Post page load injected SVGs don't automatically have their script\n // elements run, so we'll need to make that happen, if requested.\n\n // Find then prune the scripts.\n const scripts = svg.querySelectorAll('script')\n const scriptsToEval: string[] = []\n let script\n let scriptType\n\n for (let i = 0, scriptsLen = scripts.length; i < scriptsLen; i++) {\n scriptType = scripts[i].getAttribute('type')\n\n // Only process javascript types. SVG defaults to 'application/ecmascript'\n // for unset types.\n /* istanbul ignore else */\n if (\n !scriptType ||\n scriptType === 'application/ecmascript' ||\n scriptType === 'application/javascript' ||\n scriptType === 'text/javascript'\n ) {\n // innerText for IE, textContent for other browsers.\n script = scripts[i].innerText || scripts[i].textContent\n\n // Stash.\n /* istanbul ignore else */\n if (script) {\n scriptsToEval.push(script)\n }\n\n // Tidy up and remove the script element since we don't need it anymore.\n svg.removeChild(scripts[i])\n }\n }\n\n // Run/Eval the scripts if needed.\n /* istanbul ignore else */\n if (\n scriptsToEval.length > 0 &&\n (evalScripts === 'always' ||\n (evalScripts === 'once' && !ranScripts[elUrl]))\n ) {\n for (\n let l = 0, scriptsToEvalLen = scriptsToEval.length;\n l < scriptsToEvalLen;\n l++\n ) {\n // :NOTE: Yup, this is a form of eval, but it is being used to eval code\n // the caller has explictely asked to be loaded, and the code is in a\n // caller defined SVG file... not raw user input.\n //\n // Also, the code is evaluated in a closure and not in the global scope.\n // If you need to put something in global scope, use 'window'.\n new Function(scriptsToEval[l])(window)\n }\n\n // Remember we already ran scripts for this svg.\n ranScripts[elUrl] = true\n }\n\n // :WORKAROUND: IE doesn't evaluate <style> tags in SVGs that are\n // dynamically added to the page. This trick will trigger IE to read and use\n // any existing SVG <style> tags.\n //\n // Reference: https://github.com/iconic/SVGInjector/issues/23.\n const styleTags = svg.querySelectorAll('style')\n Array.prototype.forEach.call(styleTags, (styleTag: HTMLStyleElement) => {\n styleTag.textContent += ''\n })\n\n svg.setAttribute('xmlns', svgNamespace)\n svg.setAttribute('xmlns:xlink', xlinkNamespace)\n\n beforeEach(svg)\n\n if (!el.parentNode) {\n injectedElements.splice(injectedElements.indexOf(el), 1)\n ;(el as ElementType) = null\n callback(new Error('Parent node is null'))\n return\n }\n\n // Replace the image with the svg.\n el.parentNode.replaceChild(svg, el)\n\n // Now that we no longer need it, drop references to the original element so\n // it can be GC'd.\n // TODO: Extract\n injectedElements.splice(injectedElements.indexOf(el), 1)\n ;(el as ElementType) = null\n\n callback(null, svg)\n })\n}\n\nexport default injectElement\n","import injectElement from './inject-element'\nimport { AfterAll, BeforeEach, Errback, EvalScripts } from './types'\n\ntype Elements = HTMLCollectionOf<Element> | NodeListOf<Element> | Element | null\n\ninterface OptionalArgs {\n afterAll?: AfterAll\n afterEach?: Errback\n beforeEach?: BeforeEach\n cacheRequests?: boolean\n evalScripts?: EvalScripts\n httpRequestWithCredentials?: boolean\n renumerateIRIElements?: boolean\n}\n\nconst SVGInjector = (\n elements: Elements,\n {\n afterAll = () => undefined,\n afterEach = () => undefined,\n beforeEach = () => undefined,\n cacheRequests = true,\n evalScripts = 'never',\n httpRequestWithCredentials = false,\n renumerateIRIElements = true,\n }: OptionalArgs = {}\n) => {\n if (elements && 'length' in elements) {\n let elementsLoaded = 0\n for (let i = 0, j = elements.length; i < j; i++) {\n injectElement(\n elements[i],\n evalScripts,\n renumerateIRIElements,\n cacheRequests,\n httpRequestWithCredentials,\n beforeEach,\n (error, svg) => {\n afterEach(error, svg)\n if (\n elements &&\n 'length' in elements &&\n elements.length === ++elementsLoaded\n ) {\n afterAll(elementsLoaded)\n }\n }\n )\n }\n } else if (elements) {\n injectElement(\n elements,\n evalScripts,\n renumerateIRIElements,\n cacheRequests,\n httpRequestWithCredentials,\n beforeEach,\n (error, svg) => {\n afterEach(error, svg)\n afterAll(1)\n elements = null\n }\n )\n } else {\n afterAll(0)\n }\n}\n\nexport default SVGInjector\n"],"names":["cache","Map","cloneSvg","sourceSvg","cloneNode","isLocal","location","protocol","makeAjaxRequest","callback","httpRequest","onreadystatechange","test","url","readyState","contentType","Error","parseContentType","type","status","responseXML","statusText","error","abort","requestQueue","queueRequest","push","len","setTimeout","cacheValue","get","i","SVGSVGElement","length","httpRequestWithCredentials","has","undefined","set","loadSvgUncached","Document","idCounter","uniqueId","injectedElements","ranScripts","svgNamespace","xlinkNamespace","el","renumerateIRIElements","beforeEach","elUrl","getAttribute","indexOf","splice","cacheRequests","loadSvgCached","loadSvg","svg","elId","setAttribute","elTitle","elWidth","elHeight","mergedClasses","Array","from","split","join","trim","elStyle","elData","filter","call","attributes","at","name","prototype","forEach","dataAttr","value","iriElementsAndProperties_1","clipPath","linearGradient","marker","pattern","element_1","elements_1","properties_1","currentId_1","newId_1","Object","keys","key","querySelectorAll","a","elementsLen","id","property","referencingElements","SVGInjector","elements","_a","_b","_c","afterAll","_f","_g","evalScripts","_h"],"mappings":";;;AAAA,IAAWA,KAAA,GAAO,IAAAC,GAAgD,EAAA;;ACAlE,IAAMC,QAAW,GAAA,SAAXA,QAAW,CAAAC,SAAyB,EAAA;AACxC,EAAA,OAAA,SAAA,CAASC,SAAC,CAAS,IAAA,CAAuB,CAAA;AAA1C,CAA0C;;ACD5C,IAAaC,OAAA,GAAS,SAATA,OAAA,GAAS;AAAA,EAAA,OAAA,MAAA,CAAAC,QAAM,CAAAC,QAAS,KAAC,OAAQ,CAAA;AAAxB,CAAwB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