Просмотр исходного кода

don't set preserveAspectRatio to none for SVG images

Gildas 7 лет назад
Родитель
Сommit
63b7249257
2 измененных файлов с 2 добавлено и 7 удалено
  1. 1 6
      lib/single-file/doc-helper.js
  2. 1 1
      lib/single-file/html-images-minifier.js

+ 1 - 6
lib/single-file/doc-helper.js

@@ -164,7 +164,6 @@ this.docHelper = this.docHelper || (() => {
 				if (imageElement.src) {
 					let naturalWidth = imageElement.naturalWidth;
 					let naturalHeight = imageElement.naturalHeight;
-					let preserveAspectRatio = false;
 					if (naturalWidth <= 1 && naturalHeight <= 1) {
 						const imgElement = doc.createElement("img");
 						imgElement.src = imageElement.src;
@@ -172,9 +171,6 @@ this.docHelper = this.docHelper || (() => {
 						naturalWidth = imgElement.width;
 						naturalHeight = imgElement.height;
 						imgElement.remove();
-						if (naturalWidth > 1 && naturalHeight > 1) {
-							preserveAspectRatio = true;
-						}
 					}
 					imageData = {
 						width: imageElement.width,
@@ -182,8 +178,7 @@ this.docHelper = this.docHelper || (() => {
 						clientWidth: imageElement.clientWidth,
 						clientHeight: imageElement.clientHeight,
 						naturalWidth,
-						naturalHeight,
-						preserveAspectRatio
+						naturalHeight						
 					};
 				}
 				data.push(imageData);

+ 1 - 1
lib/single-file/html-images-minifier.js

@@ -114,7 +114,7 @@ this.imagesMinifier = this.imagesMinifier || (() => {
 						svgElement.setAttributeNS(SVG_NS, "viewBox", "0 0 " + width + " " + height);
 						svgElement.setAttributeNS(SVG_NS, "width", imageData.clientWidth);
 						svgElement.setAttributeNS(SVG_NS, "height", imageData.clientHeight);
-						if (!imageData.preserveAspectRatio) {
+						if (!imgElement.src.includes(".svg")) { // FIXME
 							svgElement.setAttributeNS(SVG_NS, "preserveAspectRatio", "none");
 						}
 						useElement.setAttributeNS(SVG_NS, "xlink:href", "#single-file-" + urlIndex);