|
|
@@ -99,12 +99,6 @@ this.imagesMinifier = this.imagesMinifier || (() => {
|
|
|
svgElement.setAttributeNS(SVG_NS, "height", 0);
|
|
|
svgElement.setAttributeNS(SVG_NS, "style", "display:none!important");
|
|
|
svgElement.appendChild(defsElement);
|
|
|
- duplicateURLs.forEach((src, srcIndex) => {
|
|
|
- const imageElement = doc.createElementNS(SVG_NS, "image");
|
|
|
- imageElement.setAttribute("xlink:href", src);
|
|
|
- imageElement.id = "single-file-" + srcIndex;
|
|
|
- defsElement.appendChild(imageElement);
|
|
|
- });
|
|
|
doc.body.appendChild(svgElement);
|
|
|
const ignoredAttributeNames = [];
|
|
|
if (options.lazyLoadImages) {
|
|
|
@@ -149,7 +143,13 @@ this.imagesMinifier = this.imagesMinifier || (() => {
|
|
|
svgElement.setAttributeNS(SVG_NS, "height", imageData.clientHeight);
|
|
|
svgElement.setAttributeNS(SVG_NS, "preserveAspectRatio", "none");
|
|
|
useElement.setAttributeNS(SVG_NS, "xlink:href", "#single-file-" + urlIndex);
|
|
|
- const imageElement = doc.getElementById("single-file-" + urlIndex);
|
|
|
+ let imageElement = doc.getElementById("single-file-" + urlIndex);
|
|
|
+ if (!imageElement) {
|
|
|
+ imageElement = doc.createElementNS(SVG_NS, "image");
|
|
|
+ imageElement.setAttribute("xlink:href", imgElement.src);
|
|
|
+ imageElement.id = "single-file-" + urlIndex;
|
|
|
+ defsElement.appendChild(imageElement);
|
|
|
+ }
|
|
|
if (!imageElement.getAttributeNS(SVG_NS, "width") && !imageElement.getAttributeNS(SVG_NS, "height")) {
|
|
|
imageElement.setAttributeNS(SVG_NS, "viewBox", "0 0 " + width + " " + height);
|
|
|
imageElement.setAttributeNS(SVG_NS, "width", width);
|