瀏覽代碼

prevent setting class attribute to null

Gildas 7 年之前
父節點
當前提交
1359335d75
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      lib/single-file/html-images-minifier.js

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

@@ -167,7 +167,10 @@ this.imagesMinifier = this.imagesMinifier || (() => {
 								}
 							}
 						});
-						svgElement.setAttribute("class", imgElement.getAttribute("class"));
+						const className = imgElement.getAttribute("class");
+						if (className) {
+							svgElement.setAttribute("class", className);
+						}
 						const title = imgElement.getAttribute("title");
 						if (title) {
 							const titleElement = doc.createElementNS(SVG_NS, "title");