ソースを参照

ignore pseudo-classes

Gildas 7 年 前
コミット
d533c55a9c
1 ファイル変更2 行追加1 行削除
  1. 2 1
      lib/single-file/css-rules-matcher.js

+ 2 - 1
lib/single-file/css-rules-matcher.js

@@ -24,6 +24,7 @@ this.RulesMatcher = this.RulesMatcher || (() => {
 
 	const MEDIA_ALL = "all";
 	const PRIORITY_IMPORTANT = "important";
+	const IGNORED_PSEUDO_CLASSES = [":focus", ":focus-within", ":hover", ":link", ":visited", ":active"]
 
 	class RulesMatcher {
 		constructor(doc) {
@@ -113,7 +114,7 @@ this.RulesMatcher = this.RulesMatcher || (() => {
 				specificity.sheetIndex = sheetIndex;
 				let ruleInfo = elementInfo.find(ruleInfo => ruleInfo.cssRule == cssRule);
 				if (ruleInfo) {
-					if (compareSpecificity(ruleInfo.specificity, specificity) == 1) {
+					if (!IGNORED_PSEUDO_CLASSES.find(pseudoClass => selectorText.find(pseudoClass)) && compareSpecificity(ruleInfo.specificity, specificity) == 1) {
 						ruleInfo.specificity = specificity;
 						ruleInfo.selectorText = selectorText;
 					}