Pārlūkot izejas kodu

don't ignore errors

Gildas 7 gadi atpakaļ
vecāks
revīzija
dccbeca452
1 mainītis faili ar 4 papildinājumiem un 9 dzēšanām
  1. 4 9
      lib/single-file/css-rules-matcher.js

+ 4 - 9
lib/single-file/css-rules-matcher.js

@@ -70,20 +70,15 @@ this.RulesMatcher = this.RulesMatcher || (() => {
 				getMatchedElementsRules(doc, cssRule.cssRules, ruleMediaInfo, sheetIndex, matchedElementsCache, unmatchedSelectorsCache);
 			} else if (cssRule.type == CSSRule.STYLE_RULE) {
 				if (cssRule.selectorText) {
-					try {
-						let selectors = cssWhat.parse(cssRule.selectorText);
-						const selectorsText = selectors.map(selector => cssWhat.stringify([selector]));
-						selectors.forEach(selector => getMatchedElementsSelector(doc, cssRule, selector, selectorsText, mediaInfo, ruleIndex, sheetIndex, matchedElementsCache, unmatchedSelectorsCache));
-					} catch (error) {
-						/* ignored */
-					}
+					let selectors = cssWhat.parse(cssRule.selectorText);
+					const selectorsText = selectors.map(selector => cssWhat.stringify([selector]));
+					selectors.forEach((selector, selectorIndex) => getMatchedElementsSelector(doc, cssRule, selector, selectorsText[selectorIndex], selectorsText, mediaInfo, ruleIndex, sheetIndex, matchedElementsCache, unmatchedSelectorsCache));
 				}
 			}
 		});
 	}
 
-	function getMatchedElementsSelector(doc, cssRule, selector, selectorsText, mediaInfo, ruleIndex, sheetIndex, matchedElementsCache, unmatchedSelectorsCache) {
-		const selectorText = cssWhat.stringify([selector]);
+	function getMatchedElementsSelector(doc, cssRule, selector, selectorText, selectorsText, mediaInfo, ruleIndex, sheetIndex, matchedElementsCache, unmatchedSelectorsCache) {
 		let matchedElements = matchedElementsCache.get(selectorText);
 		if (!matchedElements) {
 			if (unmatchedSelectorsCache.find(selector => selectorText.startsWith(selector))) {