|
|
@@ -1912,27 +1912,26 @@ class ProcessorHelper {
|
|
|
}
|
|
|
if (testValidURL(resourceURL)) {
|
|
|
const hashMatch = originalResourceURL.match(REGEXP_URL_HASH);
|
|
|
- if (hashMatch && hashMatch[0]) {
|
|
|
- if (originalResourceURL.startsWith(baseURI + "#")) {
|
|
|
- resourceElement.setAttribute(attributeName, hashMatch[0]);
|
|
|
- } else {
|
|
|
- const response = await batchRequest.addURL(resourceURL);
|
|
|
- const svgDoc = util.parseSVGContent(response.content);
|
|
|
+ if (originalResourceURL.startsWith(baseURI + "#")) {
|
|
|
+ resourceElement.setAttribute(attributeName, hashMatch[0]);
|
|
|
+ } else {
|
|
|
+ const response = await batchRequest.addURL(resourceURL);
|
|
|
+ const svgDoc = util.parseSVGContent(response.content);
|
|
|
+ if (hashMatch && hashMatch[0]) {
|
|
|
+ let symbolElement;
|
|
|
try {
|
|
|
- const spriteElement = svgDoc.querySelector(hashMatch[0]);
|
|
|
- if (spriteElement.tagName.toLowerCase() == "symbol") {
|
|
|
- resourceElement.after(...spriteElement.childNodes);
|
|
|
- resourceElement.remove();
|
|
|
- } else {
|
|
|
- resourceElement.parentElement.replaceChild(spriteElement, resourceElement);
|
|
|
- }
|
|
|
+ symbolElement = svgDoc.querySelector(hashMatch[0]);
|
|
|
} catch (error) {
|
|
|
// ignored
|
|
|
}
|
|
|
+ if (symbolElement) {
|
|
|
+ resourceElement.setAttribute(attributeName, hashMatch[0]);
|
|
|
+ resourceElement.parentElement.insertBefore(symbolElement, resourceElement.parentElement.firstChild);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const content = await batchRequest.addURL(resourceURL);
|
|
|
+ resourceElement.setAttribute(attributeName, PREFIX_DATA_URI_IMAGE_SVG + "," + content);
|
|
|
}
|
|
|
- } else {
|
|
|
- const content = await batchRequest.addURL(resourceURL);
|
|
|
- resourceElement.setAttribute(attributeName, PREFIX_DATA_URI_IMAGE_SVG + "," + content);
|
|
|
}
|
|
|
}
|
|
|
} else if (resourceURL == options.url) {
|