Ver Fonte

ignore pseudo-classes and pseudo-elements

Gildas há 7 anos atrás
pai
commit
6a6b4a3c39
1 ficheiros alterados com 5 adições e 5 exclusões
  1. 5 5
      lib/single-file/css-rules-matcher.js

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

@@ -23,7 +23,7 @@
 this.RulesMatcher = this.RulesMatcher || (() => {
 
 	const MEDIA_ALL = "all";
-	const IGNORED_PSEUDO_CLASSES = [":focus", ":focus-within", ":hover", ":link", ":visited", ":active"];
+	const IGNORED_PSEUDOS = [":focus", ":focus-within", ":hover", ":link", ":visited", ":active", "::after", "::before", "::first-line", "::first-letter", "::placeholder", "::selection", "::marker", "::cue"];
 	const SELECTOR_TOKEN_TYPE_TAG = "tag";
 	const SELECTOR_TOKEN_TYPE_ATTRIBUTE = "attribute";
 	const SELECTOR_TOKEN_TYPE_PSEUDO = "pseudo";
@@ -135,11 +135,11 @@ this.RulesMatcher = this.RulesMatcher || (() => {
 		const { elementInfo, ruleInfo, specificity } = info;
 		if (ruleInfo) {
 			if (compareSpecificity(ruleInfo.specificity, specificity) == 1) {
-				let pseudoClassIndex = 0, pseudoClassesLength = IGNORED_PSEUDO_CLASSES.length, ignoredPseudoClass;
-				while (pseudoClassIndex < pseudoClassesLength && !(ignoredPseudoClass = selectorText.includes(IGNORED_PSEUDO_CLASSES[pseudoClassIndex]))) {
-					pseudoClassIndex++;
+				let pseudoIndex = 0, pseudoLength = IGNORED_PSEUDOS.length, ignoredPseudo;
+				while (pseudoIndex < pseudoLength && !(ignoredPseudo = selectorText.includes(IGNORED_PSEUDOS[pseudoIndex]))) {
+					pseudoIndex++;
 				}
-				if (!ignoredPseudoClass || pseudoClassIndex < pseudoClassesLength) {
+				if (!ignoredPseudo || pseudoIndex < pseudoLength) {
 					ruleInfo.specificity = specificity;
 					ruleInfo.selectorText = selectorText;
 				}