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

+ 6 - 2
lib/single-file/html-images-minifier.js

@@ -26,6 +26,7 @@ this.imagesMinifier = this.imagesMinifier || (() => {
 	const SVG_NS = "http://www.w3.org/2000/svg";
 	const SVG_NS = "http://www.w3.org/2000/svg";
 	const PREFIX_DATA_URI_IMAGE_SVG = "data:image/svg+xml";
 	const PREFIX_DATA_URI_IMAGE_SVG = "data:image/svg+xml";
 	const TRANSFORMED_IMAGE_ATTRIBUTE = "data-single-file-image-transform";
 	const TRANSFORMED_IMAGE_ATTRIBUTE = "data-single-file-image-transform";
+	const IGNORED_ATTRIBUTES = ["src", "width", "height", "viewBox", "preserveAspectRatio", "xlink:href"];
 
 
 	return {
 	return {
 		process: (doc, mediaAllInfo, options) => {
 		process: (doc, mediaAllInfo, options) => {
@@ -127,13 +128,16 @@ this.imagesMinifier = this.imagesMinifier || (() => {
 						const svgElement = doc.createElementNS(SVG_NS, "svg");
 						const svgElement = doc.createElementNS(SVG_NS, "svg");
 						const useElement = doc.createElementNS(SVG_NS, "use");
 						const useElement = doc.createElementNS(SVG_NS, "use");
 						svgElement.appendChild(useElement);
 						svgElement.appendChild(useElement);
+						if (imgElement.src.includes("mainv_hayabusa2.png")) {
+							debugger
+						}
 						imgElement.getAttributeNames().forEach(attributeName => {
 						imgElement.getAttributeNames().forEach(attributeName => {
 							try {
 							try {
-								if (attributeName != "src") {
+								if (!IGNORED_ATTRIBUTES.includes(attributeName)) {
 									svgElement.setAttribute(attributeName, imgElement.getAttribute(attributeName));
 									svgElement.setAttribute(attributeName, imgElement.getAttribute(attributeName));
 								}
 								}
 							} catch (error) {
 							} catch (error) {
-								if (attributeName != "src") {
+								if (!IGNORED_ATTRIBUTES.includes(attributeName)) {
 									try {
 									try {
 										svgElement.setAttributeNS(SVG_NS, attributeName, imgElement.getAttribute(attributeName));
 										svgElement.setAttributeNS(SVG_NS, attributeName, imgElement.getAttribute(attributeName));
 									} catch (error) {
 									} catch (error) {