Gildas 7 lat temu
rodzic
commit
320adb861a
1 zmienionych plików z 24 dodań i 26 usunięć
  1. 24 26
      lib/single-file/rules-matcher.js

+ 24 - 26
lib/single-file/rules-matcher.js

@@ -118,32 +118,30 @@ this.RulesMatcher = this.RulesMatcher || (() => {
 	}
 
 	function computeCascade(mediaInfo, parentMediaInfos, allMediaInfo) {
-		mediaInfo.elements.forEach(elementInfo => {
-			getStylesInfo(elementInfo).forEach((elementStyleInfo, styleName) => {
-				let ruleInfo, ascendantMedia;
-				if (elementStyleInfo.cssRule) {
-					ascendantMedia = [mediaInfo, ...parentMediaInfos].find(media => media.rules.get(elementStyleInfo.cssRule)) || mediaInfo;
-					ruleInfo = ascendantMedia.rules.get(elementStyleInfo.cssRule);
-				} else if (mediaInfo == allMediaInfo) {
-					ruleInfo = allMediaInfo.styles.get(elementStyleInfo.cssStyle);
-				}
-				if (!ruleInfo) {
-					ruleInfo = { style: new Map(), matchedSelectors: new Set(), selectorsText: elementStyleInfo.selectorsText };
-				}
-				if (elementStyleInfo.cssRule) {
-					ascendantMedia.rules.set(elementStyleInfo.cssRule, ruleInfo);
-				} else if (mediaInfo == allMediaInfo) {
-					allMediaInfo.styles.set(elementStyleInfo.cssStyle, ruleInfo);
-				}
-				if (elementStyleInfo.selectorText) {
-					ruleInfo.matchedSelectors.add(elementStyleInfo.selectorText);
-				}
-				const styleValue = ruleInfo.style.get(styleName);
-				if (!styleValue) {
-					ruleInfo.style.set(styleName, elementStyleInfo.styleValue);
-				}
-			});
-		});
+		mediaInfo.elements.forEach(elementInfo => getStylesInfo(elementInfo).forEach((elementStyleInfo, styleName) => {
+			let ruleInfo, ascendantMedia;
+			if (elementStyleInfo.cssRule) {
+				ascendantMedia = [mediaInfo, ...parentMediaInfos].find(media => media.rules.get(elementStyleInfo.cssRule)) || mediaInfo;
+				ruleInfo = ascendantMedia.rules.get(elementStyleInfo.cssRule);
+			} else if (mediaInfo == allMediaInfo) {
+				ruleInfo = allMediaInfo.styles.get(elementStyleInfo.cssStyle);
+			}
+			if (!ruleInfo) {
+				ruleInfo = { style: new Map(), matchedSelectors: new Set(), selectorsText: elementStyleInfo.selectorsText };
+			}
+			if (elementStyleInfo.cssRule) {
+				ascendantMedia.rules.set(elementStyleInfo.cssRule, ruleInfo);
+			} else if (mediaInfo == allMediaInfo) {
+				allMediaInfo.styles.set(elementStyleInfo.cssStyle, ruleInfo);
+			}
+			if (elementStyleInfo.selectorText) {
+				ruleInfo.matchedSelectors.add(elementStyleInfo.selectorText);
+			}
+			const styleValue = ruleInfo.style.get(styleName);
+			if (!styleValue) {
+				ruleInfo.style.set(styleName, elementStyleInfo.styleValue);
+			}
+		}));
 		mediaInfo.medias.forEach(childMediaInfo => computeCascade(childMediaInfo, [mediaInfo, ...parentMediaInfos]));
 	}