Browse Source

convert to lowercase values of font properties

Former-commit-id: 708e7956ab2538ccd58e6ca9e63d403e44088413
= 6 years ago
parent
commit
0fbc96463a
1 changed files with 5 additions and 6 deletions
  1. 5 6
      lib/single-file/modules/css-fonts-minifier.js

+ 5 - 6
lib/single-file/modules/css-fonts-minifier.js

@@ -36,6 +36,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
 	const REGEXP_SIMPLE_QUOTES_STRING = /^'(.*?)'$/;
 	const REGEXP_DOUBLE_QUOTES_STRING = /^"(.*?)"$/;
 	const FONT_WEIGHTS = {
+		regular: "400",
 		normal: "400",
 		bold: "700",
 		bolder: "700",
@@ -182,7 +183,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
 		}
 		if (property) {
 			try {
-				return singlefile.lib.vendor.cssTree.generate(property.data.value);
+				return singlefile.lib.helper.removeQuotes(singlefile.lib.vendor.cssTree.generate(property.data.value));
 			} catch (error) {
 				// ignored
 			}
@@ -286,12 +287,11 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
 	}
 
 	function getDeclarationUnescapedValue(declarations, property, workStylesheet) {
-		const helper = singlefile.lib.helper;
-		const rawValue = helper.removeQuotes(getDeclarationValue(declarations, property) || "");
+		const rawValue = getDeclarationValue(declarations, property) || "";
 		if (rawValue) {
 			workStylesheet.textContent = "tmp { content:\"" + rawValue + "\"}";
 			if (workStylesheet.sheet && workStylesheet.sheet.cssRules) {
-				return helper.removeQuotes(workStylesheet.sheet.cssRules[0].style.getPropertyValue("content"));
+				return singlefile.lib.helper.removeQuotes(workStylesheet.sheet.cssRules[0].style.getPropertyValue("content"));
 			} else {
 				return rawValue;
 			}
@@ -305,7 +305,6 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
 
 	function testUnicodeRange(docContent, unicodeRange) {
 		if (unicodeRange) {
-			unicodeRange = singlefile.lib.helper.removeQuotes(unicodeRange);
 			const unicodeRanges = unicodeRange.split(REGEXP_COMMA);
 			let invalid;
 			const result = unicodeRanges.filter(rangeValue => {
@@ -358,7 +357,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
 	}
 
 	function getFontWeight(weight) {
-		return FONT_WEIGHTS[weight] || weight;
+		return FONT_WEIGHTS[weight.toLowerCase()] || weight;
 	}
 
 })();