Explorar el Código

fixed regression of "remove unused styles" option

Gildas hace 7 años
padre
commit
34a902aa0e
Se han modificado 2 ficheros con 5 adiciones y 7 borrados
  1. 3 5
      lib/single-file/css-rules-matcher.js
  2. 2 2
      lib/single-file/css-rules-minifier.js

+ 3 - 5
lib/single-file/css-rules-matcher.js

@@ -194,12 +194,10 @@ this.RulesMatcher = this.RulesMatcher || (() => {
 			} else {
 				const styleInfo = elementStyleInfo.selectorInfo.styleInfo;
 				const cssStyle = styleInfo.cssStyle;
-				let styleInfos = mediaAllInfo.matchedStyles.get(cssStyle);
-				if (!styleInfos) {
-					styleInfos = [];
-					mediaAllInfo.matchedStyles.set(cssStyle, styleInfos);
+				let matchedStyleInfo = mediaAllInfo.matchedStyles.get(cssStyle);
+				if (!matchedStyleInfo) {
+					mediaAllInfo.matchedStyles.set(cssStyle, styleInfo);
 				}
-				styleInfos.push(styleInfo);
 				const styleValue = styleInfo.style.get(styleName);
 				if (!styleValue) {
 					styleInfo.style.set(styleName, elementStyleInfo.styleValue);

+ 2 - 2
lib/single-file/css-rules-minifier.js

@@ -127,11 +127,11 @@ this.cssMinifier = this.cssMinifier || (() => {
 		let styleCssText = "";
 		const styleInfos = mediaAllInfo.matchedStyles.get(cssStyle);
 		if (styleInfos) {
-			styleInfos.forEach(styleInfo => {
+			styleInfos.style.forEach((styleValue, styleName) => {
 				const stylesInfo = parseCss.parseAListOfDeclarations(cssStyle.cssText);
 				for (let styleIndex = 0; styleIndex < stylesInfo.length; styleIndex++) {
 					const style = stylesInfo[styleIndex];
-					if (styleInfo.style.get(style.name)) {
+					if (styleName == style.name) {
 						if (styleCssText) {
 							styleCssText += ";";
 						}