Explorar o código

fixed parsing of "font-faimily" property

Gildas %!s(int64=7) %!d(string=hai) anos
pai
achega
e28feb9d2d
Modificáronse 1 ficheiros con 12 adicións e 1 borrados
  1. 12 1
      lib/single-file/css-fonts-minifier.js

+ 12 - 1
lib/single-file/css-fonts-minifier.js

@@ -182,7 +182,18 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 		let fontFamilyName = declarations.children.filter(node => node.property == "font-family").tail;
 		let fontFamilyNames = [];
 		if (fontFamilyName) {
-			fontFamilyNames = fontFamilyName.data.value.children.filter(node => node.type == "String" || node.type == "Identifier").toArray().map(property => getFontFamily(cssTree.generate(property)));
+			let familyName = "";
+			fontFamilyName.data.value.children.forEach(node => {
+				if (node.type == "Operator" && node.value == "," && familyName) {
+					fontFamilyNames.push(getFontFamily(familyName));
+					familyName = "";
+				} else {
+					familyName += cssTree.generate(node);
+				}
+			});
+			if (familyName) {
+				fontFamilyNames.push(getFontFamily(familyName));
+			}
 		}
 		const font = declarations.children.filter(node => node.property == "font").tail;
 		if (font) {